Bugzilla – Attachment 113535 Details for
Bug 26988
Defer loading the hold pickup locations until the dropdown is selected
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 26988: (QA follow-up) Make the API return proper library objects
Bug-26988-QA-follow-up-Make-the-API-return-proper-.patch (text/plain), 2.38 KB, created by
Tomás Cohen Arazi (tcohen)
on 2020-11-11 19:16:18 UTC
(
hide
)
Description:
Bug 26988: (QA follow-up) Make the API return proper library objects
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2020-11-11 19:16:18 UTC
Size:
2.38 KB
patch
obsolete
>From 1c5c4d08e2f0cdc35cf038f02ccf435ec032c64c Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Tue, 10 Nov 2020 17:38:26 -0300 >Subject: [PATCH] Bug 26988: (QA follow-up) Make the API return proper library > objects > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > Koha/REST/V1/Holds.pm | 16 +++++++++++----- > api/v1/swagger/paths/holds.json | 8 +++++++- > 2 files changed, 18 insertions(+), 6 deletions(-) > >diff --git a/Koha/REST/V1/Holds.pm b/Koha/REST/V1/Holds.pm >index 8239a621867..20f76a13f69 100644 >--- a/Koha/REST/V1/Holds.pm >+++ b/Koha/REST/V1/Holds.pm >@@ -406,7 +406,7 @@ sub pickup_locations { > my $c = shift->openapi->valid_input or return; > > my $hold_id = $c->validation->param('hold_id'); >- my $hold = Koha::Holds->find($hold_id); >+ my $hold = Koha::Holds->find( $hold_id, { prefetch => [ 'patron' ] } ); > > unless ($hold) { > return $c->render( >@@ -416,11 +416,17 @@ sub pickup_locations { > } > > return try { >- my $pickup_locations = $hold->itemnumber ? >- $hold->item->pickup_locations({ patron => $hold->patron }) : $hold->biblio->pickup_locations({ patron => $hold->patron }); >- warn Data::Dumper::Dumper( $pickup_locations ); >+ my @pickup_locations = >+ $hold->itemnumber >+ ? @{ $hold->item->pickup_locations( { patron => $hold->patron } ) } >+ : @{ $hold->biblio->pickup_locations( { patron => $hold->patron } ) }; >+ >+ @pickup_locations = map { $_->to_api } @pickup_locations; > >- return $c->render( status => 200, openapi => $pickup_locations ); >+ return $c->render( >+ status => 200, >+ openapi => \@pickup_locations >+ ); > } > catch { > $c->unhandled_exception($_); >diff --git a/api/v1/swagger/paths/holds.json b/api/v1/swagger/paths/holds.json >index b375ea72ddb..3792985c8cb 100644 >--- a/api/v1/swagger/paths/holds.json >+++ b/api/v1/swagger/paths/holds.json >@@ -625,7 +625,13 @@ > "produces": ["application/json"], > "responses": { > "200": { >- "description": "Hold pickup location" >+ "description": "Hold pickup location", >+ "schema": { >+ "type": "array", >+ "items": { >+ "$ref": "../definitions.json#/library" >+ } >+ } > }, > "400": { > "description": "Missing or wrong parameters", >-- >2.29.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 26988
:
113395
|
113418
|
113426
|
113427
|
113428
|
113456
|
113457
|
113458
|
113459
|
113460
|
113502
|
113533
|
113534
| 113535 |
113536
|
113537
|
113538
|
113590
|
113601
|
113669