Bugzilla – Attachment 115773 Details for
Bug 27544
Simplify /checkouts implementation
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 27544: Simplify GET /checkouts implementation
Bug-27544-Simplify-GET-checkouts-implementation.patch (text/plain), 3.03 KB, created by
Jonathan Druart
on 2021-01-25 14:00:25 UTC
(
hide
)
Description:
Bug 27544: Simplify GET /checkouts implementation
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2021-01-25 14:00:25 UTC
Size:
3.03 KB
patch
obsolete
>From d7ab2c51cf99d2cb363a4cb0b1b97fc58b6ac0b7 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Mon, 25 Jan 2021 10:35:20 -0300 >Subject: [PATCH] Bug 27544: Simplify GET /checkouts implementation > >This patch makes the list() controller method simpler, by removing the >checked_in parameter, and passing the appropriate restulset. > >To test: >1. Run: > $ kshell > k$ prove t/db_dependent/api/v1/checkouts.t >=> SUCCESS: Tests pass! >2. Apply this patch >3. Repeat (1) >=> SUCCESS: Tests still pass! (no behaviour change) >4. Sign off :-D > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> > >Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >--- > Koha/REST/V1/Checkouts.pm | 47 +++++---------------------------------- > 1 file changed, 5 insertions(+), 42 deletions(-) > >diff --git a/Koha/REST/V1/Checkouts.pm b/Koha/REST/V1/Checkouts.pm >index 93feeaeb24..8fc07181b1 100644 >--- a/Koha/REST/V1/Checkouts.pm >+++ b/Koha/REST/V1/Checkouts.pm >@@ -45,7 +45,7 @@ List Koha::Checkout objects > sub list { > my $c = shift->openapi->valid_input or return; > >- my $checked_in = $c->validation->param('checked_in'); >+ my $checked_in = delete $c->validation->output->{checked_in}; > > try { > my $checkouts_set; >@@ -56,49 +56,12 @@ sub list { > $checkouts_set = Koha::Checkouts->new; > } > >- my $args = $c->validation->output; >- my $attributes = {}; >+ my $checkouts = $c->objects->search( $checkouts_set ); > >- # Extract reserved params >- my ( $filtered_params, $reserved_params ) = $c->extract_reserved_params($args); >- >- # Merge sorting into query attributes >- $c->dbic_merge_sorting( >- { >- attributes => $attributes, >- params => $reserved_params, >- result_set => $checkouts_set >- } >- ); >- >- # Merge pagination into query attributes >- $c->dbic_merge_pagination( >- { >- filter => $attributes, >- params => $reserved_params >- } >+ return $c->render( >+ status => 200, >+ openapi => $checkouts > ); >- >- # Call the to_model function by reference, if defined >- if ( defined $filtered_params ) { >- # remove checked_in >- delete $filtered_params->{checked_in}; >- # Apply the mapping function to the passed params >- $filtered_params = $checkouts_set->attributes_from_api($filtered_params); >- $filtered_params = $c->build_query_params( $filtered_params, $reserved_params ); >- } >- >- # Perform search >- my $checkouts = $checkouts_set->search( $filtered_params, $attributes ); >- >- if ($checkouts->is_paged) { >- $c->add_pagination_headers({ >- total => $checkouts->pager->total_entries, >- params => $args, >- }); >- } >- >- return $c->render( status => 200, openapi => $checkouts->to_api ); > } catch { > $c->unhandled_exception($_); > }; >-- >2.20.1
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 27544
:
115770
|
115772
|
115773
|
115778