Bugzilla – Attachment 124904 Details for
Bug 29032
ILL route unusable (slow)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 29032: Pre-load ILL backends to speed up response
Bug-29032-Pre-load-ILL-backends-to-speed-up-respon.patch (text/plain), 2.89 KB, created by
Andrew Fuerste-Henry
on 2021-09-15 17:49:26 UTC
(
hide
)
Description:
Bug 29032: Pre-load ILL backends to speed up response
Filename:
MIME Type:
Creator:
Andrew Fuerste-Henry
Created:
2021-09-15 17:49:26 UTC
Size:
2.89 KB
patch
obsolete
>From a63d5b831aa24f5e0bb855a2d485dd679943b658 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Wed, 15 Sep 2021 12:12:33 -0300 >Subject: [PATCH] Bug 29032: Pre-load ILL backends to speed up response > >Bug 22440 will rewrite the route and make it even more efficient by >prefetching the related data instead of performing several queries in >loops. > >In the meantime, we can make this controller perform better with a >simple intervention: load backends once, and use the >$request->_backend() setter to pre-set it before using the objects. > >To test: >1. Perform any usual ILL requests listing, try having several >=> FAIL: Notice it takes a weird amount of time to load >2. Apply this patch >3. Restart all >4. Repeat 1 >=> SUCCESS: It feels fast enough! >5. Sign off :-D > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> > >Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com> >--- > Koha/REST/V1/Illrequests.pm | 16 ++++++++++++---- > 1 file changed, 12 insertions(+), 4 deletions(-) > >diff --git a/Koha/REST/V1/Illrequests.pm b/Koha/REST/V1/Illrequests.pm >index 24f93cbffa..5eb95231cc 100644 >--- a/Koha/REST/V1/Illrequests.pm >+++ b/Koha/REST/V1/Illrequests.pm >@@ -58,7 +58,7 @@ sub list { > # Get the pipe-separated string of hidden ILL statuses > my $hidden_statuses_string = C4::Context->preference('ILLHiddenRequestStatuses') // q{}; > # Turn into arrayref >- my $hidden_statuses = [ split /\|/, $hidden_statuses_string ]; >+ my $hidden_statuses = [ split "|", $hidden_statuses_string ]; > > # Get all requests > # If necessary, only get those from a specified patron >@@ -71,6 +71,15 @@ sub list { > : () > })->as_list; > >+ my $fetch_backends = {}; >+ foreach my $request (@requests) { >+ $fetch_backends->{ $request->backend } ||= >+ Koha::Illrequest->new->load_backend( $request->backend ); >+ } >+ >+ # Pre-load the backend object to avoid useless backend lookup/loads >+ @requests = map { $_->_backend( $fetch_backends->{ $_->backend } ); $_ } @requests; >+ > # Identify patrons & branches that > # we're going to need and get them > my $to_fetch = { >@@ -78,7 +87,7 @@ sub list { > branches => {}, > capabilities => {} > }; >- foreach my $req(@requests) { >+ 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}; >@@ -113,8 +122,7 @@ sub list { > my @backends = keys %{$to_fetch->{capabilities}}; > if (scalar @backends > 0) { > foreach my $bc(@backends) { >- my $backend = Koha::Illrequest->new->load_backend($bc); >- $to_fetch->{$bc} = $backend->capabilities; >+ $to_fetch->{$bc} = $fetch_backends->{$bc}->capabilities; > } > } > } >-- >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 29032
:
124899
|
124904
|
124906
|
125107