Bugzilla – Attachment 147663 Details for
Bug 33080
Add helpers that return result_set for further processing
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 33080: (follow-up) Minor cleanups
Bug-33080-follow-up-Minor-cleanups.patch (text/plain), 4.54 KB, created by
Martin Renvoize (ashimema)
on 2023-03-02 17:25:31 UTC
(
hide
)
Description:
Bug 33080: (follow-up) Minor cleanups
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2023-03-02 17:25:31 UTC
Size:
4.54 KB
patch
obsolete
>From 37a4fc16e56ddb646b1cdbe4390aeb9337d8901f Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Thu, 2 Mar 2023 16:41:31 +0000 >Subject: [PATCH] Bug 33080: (follow-up) Minor cleanups > >Whilst reviewing I spotted a few calls to the stash that were no longer >required and errors in the POD for the new/updated methods > >This patch adds fixes for those minor issues. > >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > Koha/REST/Plugin/Objects.pm | 45 ++++++++++++++++++++----------------- > 1 file changed, 24 insertions(+), 21 deletions(-) > >diff --git a/Koha/REST/Plugin/Objects.pm b/Koha/REST/Plugin/Objects.pm >index 496b7cb886..bb1bded827 100644 >--- a/Koha/REST/Plugin/Objects.pm >+++ b/Koha/REST/Plugin/Objects.pm >@@ -38,10 +38,12 @@ sub register { > > my $patrons_rs = Koha::Patrons->new; > my $patrons = $c->objects->find( $patrons_rs, $id ); >+ . . . >+ return $c->render({ status => 200, openapi => $patron }); > > Performs a database search using given Koha::Objects object and the $id. > >-Returns I<undef> if no object is found Returns the I<API representation> of >+Returns I<undef> if no object is found or the I<API representation> of > the requested object. It passes through any embeds if specified. > > =cut >@@ -55,27 +57,27 @@ the requested object. It passes through any embeds if specified. > } > ); > >+ > =head3 objects.find_rs > > my $patrons_rs = Koha::Patrons->new; >- my $patrons = $c->objects->find_rs( $patrons_rs, $id ); >+ my $patron_rs = $c->objects->find_rs( $patrons_rs, $id ); >+ . . . >+ return $c->render({ status => 200, openapi => $patron_rs->to_api }); > >-Performs a database search using given Koha::Objects object and the $id. >+Returns the passed Koha::Objects resultset filtered to the passed $id and >+with any embeds requested by the api applied. > >-Returns a new resultset for further processing. It passes through any embeds if specified. >+The resultset can then be used for further processing. > > =cut > > $app->helper( > 'objects.find_rs' => sub { > my ( $c, $result_set, $id ) = @_; >- >+ > my $attributes = {}; >- >- # Look for embeds >- my $embed = $c->stash('koha.embed'); >- my $strings = $c->stash('koha.strings'); >- >+ > # Generate prefetches for embedded stuff > $c->dbic_merge_prefetch( > { >@@ -83,9 +85,9 @@ Returns a new resultset for further processing. It passes through any embeds if > result_set => $result_set > } > ); >- >+ > my $object = $result_set->find( $id, $attributes ); >- >+ > return $object; > } > ); >@@ -94,8 +96,11 @@ Returns a new resultset for further processing. It passes through any embeds if > > my $patrons_rs = Koha::Patrons->new; > my $patrons = $c->objects->search( $patrons_rs ); >+ . . . >+ return $c->render({ status => 200, openapi => $patrons }); > >-Performs a database search using given Koha::Objects object and query parameters. >+Performs a database search using given Koha::Objects object with any api >+query parameters applied. > > Returns an arrayref of the hashrefs representing the resulting objects > for API rendering. >@@ -108,7 +113,7 @@ shouldn't be called twice in it. > $app->helper( > 'objects.search' => sub { > my ( $c, $result_set ) = @_; >- >+ > return $c->objects->to_api( $c->objects->search_rs($result_set) ); > } > ); >@@ -116,11 +121,12 @@ shouldn't be called twice in it. > =head3 objects.search_rs > > my $patrons_rs = Koha::Patrons->new; >- my $filtered_patrons_rs = $c->objects->search_rs( $patrons_rs ); >- >-Performs a database search using given Koha::Objects object and query parameters. >+ my $patrons_rs = $c->objects->search_rs( $patrons_rs ); >+ . . . >+ return $c->render({ status => 200, openapi => $patrons_rs->to_api }); > >-Returns a new resultset for further processing. >+Returns the passed Koha::Objects resultset filtered as requested by the api query >+parameters and with requested embeds applied. > > Warning: this helper adds pagination headers to the calling controller, and thus > shouldn't be called twice in it. >@@ -138,9 +144,6 @@ shouldn't be called twice in it. > my ( $filtered_params, $reserved_params, $path_params ) = > $c->extract_reserved_params($args); > >- # Privileged reques? >- my $is_public = $c->stash('is_public'); >- > # Merge sorting into query attributes > $c->dbic_merge_sorting( > { >-- >2.39.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 33080
:
147469
|
147662
|
147663
|
147720
|
147734
|
147735
|
147736
|
147788
|
147789
|
147790
|
147823
|
147824
|
147825
|
148020
|
148021
|
148022
|
148071
|
148072
|
148073