Bugzilla – Attachment 76705 Details for
Bug 20996
Fix API response time on ILL request endpoint
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 20996: Further enhance performance
Bug-20996-Further-enhance-performance.patch (text/plain), 3.90 KB, created by
Andrew Isherwood
on 2018-07-05 14:20:49 UTC
(
hide
)
Description:
Bug 20996: Further enhance performance
Filename:
MIME Type:
Creator:
Andrew Isherwood
Created:
2018-07-05 14:20:49 UTC
Size:
3.90 KB
patch
obsolete
>From f91f5440e6411f08695389fb20f5965a569d3c61 Mon Sep 17 00:00:00 2001 >From: Andrew Isherwood <andrew.isherwood@ptfs-europe.com> >Date: Thu, 5 Jul 2018 14:46:16 +0100 >Subject: [PATCH] Bug 20996: Further enhance performance > >We were immediately unblessing all request objects after retrieval then, >at a later stage, re-instantiating each one so we could call methods on >that. This was a very bad idea. We now preserve the objects for as long >as we can. >--- > Koha/REST/V1/Illrequests.pm | 44 +++++++++++++++++++++++--------------------- > 1 file changed, 23 insertions(+), 21 deletions(-) > >diff --git a/Koha/REST/V1/Illrequests.pm b/Koha/REST/V1/Illrequests.pm >index 59e3f82a44..0a6dee0e2b 100644 >--- a/Koha/REST/V1/Illrequests.pm >+++ b/Koha/REST/V1/Illrequests.pm >@@ -51,18 +51,20 @@ sub list { > delete $args->{embed}; > } > >- my $requests = Koha::Illrequests->unblessed; >+ # Get all requests >+ my @requests = Koha::Illrequests->as_list; > > # Identify patrons & branches that > # we're going to need and get them >- my $to_fetch = {}; >- $to_fetch->{patrons} = {} if $embed{patron}; >- $to_fetch->{branches} = {} if $embed{library}; >- $to_fetch->{capabilities} = {} if $embed{capabilities}; >- foreach my $req(@{$requests}) { >- $to_fetch->{patrons}->{$req->{borrowernumber}} = 1 if $embed{patron}; >- $to_fetch->{branches}->{$req->{branchcode}} = 1 if $embed{library}; >- $to_fetch->{capabilities}->{$req->{backend}} = 1 if $embed{capabilities}; >+ my $to_fetch = { >+ patrons => {}, >+ branches => {}, >+ capabilities => {} >+ }; >+ foreach my $req(@requests) { >+ $to_fetch->{patrons}->{$req->borrowernumber} = 1 if $embed{patron}; >+ $to_fetch->{branches}->{$req->branchcode} = 1 if $embed{library}; >+ $to_fetch->{capabilities}->{$req->backend} = 1 if $embed{capabilities}; > } > > # Fetch the patrons we need >@@ -100,15 +102,14 @@ sub list { > } > } > >- > # Now we've got all associated users and branches, > # we can augment the request objects >- foreach my $req(@{$requests}) { >- my $r = Koha::Illrequests->new->find($req->{illrequest_id}); >- $req->{id_prefix} = $r->id_prefix; >+ my @output = (); >+ foreach my $req(@requests) { >+ my $to_push = $req->unblessed; > foreach my $p(@{$patron_arr}) { >- if ($p->{borrowernumber} == $req->{borrowernumber}) { >- $req->{patron} = { >+ if ($p->{borrowernumber} == $req->borrowernumber) { >+ $to_push->{patron} = { > firstname => $p->{firstname}, > surname => $p->{surname}, > cardnumber => $p->{cardnumber} >@@ -117,28 +118,29 @@ sub list { > } > } > foreach my $b(@{$branch_arr}) { >- if ($b->{branchcode} eq $req->{branchcode}) { >- $req->{library} = $b; >+ if ($b->{branchcode} eq $req->branchcode) { >+ $to_push->{library} = $b; > last; > } > } > if ($embed{metadata}) { > my $metadata = Koha::Illrequestattributes->search( >- { illrequest_id => $req->{illrequest_id} }, >+ { illrequest_id => $req->illrequest_id }, > { columns => [qw/type value/] } > )->unblessed; > my $meta_hash = {}; > foreach my $meta(@{$metadata}) { > $meta_hash->{$meta->{type}} = $meta->{value}; > } >- $req->{metadata} = $meta_hash; >+ $to_push->{metadata} = $meta_hash; > } > if ($embed{capabilities}) { >- $req->{capabilities} = $to_fetch->{$req->{backend}}; >+ $to_push->{capabilities} = $to_fetch->{$req->backend}; > } >+ push @output, $to_push; > } > >- return $c->render( status => 200, openapi => $requests ); >+ return $c->render( status => 200, openapi => \@output ); > } > > 1; >-- >2.11.0
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 20996
:
76687
|
76688
|
76705
|
77100
|
79379
|
79576
|
79583
|
79584
|
79585
|
79586
|
79587
|
79588
|
79589
|
79590
|
79591
|
79592
|
81715
|
81716
|
81717
|
81718
|
81719
|
81720
|
81747
|
81748
|
81749
|
81750
|
81751
|
81752
|
81753
|
81755
|
81756
|
81757
|
81758
|
81759
|
81760
|
81761
|
81908
|
81909
|
81928
|
81967
|
81994
|
81996
|
81997
|
81998