Bugzilla – Attachment 120298 Details for
Bug 26587
Cache libraries in Branches TT plugin to improve performance
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Cache Koha::Library object in Branches template plugin
0002-Bug-26587-Cache-authorised-values-in-C4-Items-GetIte.patch (text/plain), 4.86 KB, created by
Björn Nylén
on 2021-04-29 09:45:52 UTC
(
hide
)
Description:
Cache Koha::Library object in Branches template plugin
Filename:
MIME Type:
Creator:
Björn Nylén
Created:
2021-04-29 09:45:52 UTC
Size:
4.86 KB
patch
obsolete
>From 457a470e9bc997c6557cc6b8e1608aa2dc239978 Mon Sep 17 00:00:00 2001 >From: =?UTF-8?q?Bj=C3=B6rn=20Nyl=C3=A9n?= <bjorn.nylen@ub.lu.se> >Date: Thu, 29 Apr 2021 11:32:05 +0200 >Subject: [PATCH 2/2] Bug 26587: Cache authorised values in > C4::Items::GetItemsInfo to improve performance > > This patch caches the authorised value descriptions in C4::Items::GetItemsInfo while > looping through items. Improves performance for biblios with very large number of items. > > To test: > 1. Have a biblio with many items (1000's). > 2. View in staff (detail.pl) and opac (opac-detail.pl). Note how long it takes to load. > 3. Apply patch. > 4. Repeat 2. Note that pages load faster. > >Sponsored-by: Lund University Library >--- > C4/Items.pm | 37 +++++++++++++++++++++++++++---------- > 1 file changed, 27 insertions(+), 10 deletions(-) > >diff --git a/C4/Items.pm b/C4/Items.pm >index 726c7e4cd8..9875ce7598 100644 >--- a/C4/Items.pm >+++ b/C4/Items.pm >@@ -770,18 +770,35 @@ sub GetItemsInfo { > > my $descriptions; > # get notforloan complete status if applicable >- $descriptions = Koha::AuthorisedValues->get_description_by_koha_field({frameworkcode => $data->{frameworkcode}, kohafield => 'items.notforloan', authorised_value => $data->{itemnotforloan} }); >- $data->{notforloanvalue} = $descriptions->{lib} // ''; >- $data->{notforloanvalueopac} = $descriptions->{opac_description} // ''; >- >+ if (exists $av_cache->{$data->{frameworkcode}}->{'items.notforloan'}->{$data->{itemnotforloan}} ){ >+ $data->{notforloanvalue} = $av_cache->{$data->{frameworkcode}}->{'items.notforloan'}->{$data->{itemnotforloan}}->{lib}; >+ $data->{notforloanvalueopac} = $av_cache->{$data->{frameworkcode}}->{'items.notforloan'}->{$data->{itemnotforloan}}->{opac_description}; >+ }else{ >+ $descriptions = Koha::AuthorisedValues->get_description_by_koha_field({frameworkcode => $data->{frameworkcode}, kohafield => 'items.notforloan', authorised_value => $data->{itemnotforloan} }); >+ $data->{notforloanvalue} = $descriptions->{lib} // ''; >+ $data->{notforloanvalueopac} = $descriptions->{opac_description} // ''; >+ $av_cache->{$data->{frameworkcode}}->{'items.notforloan'}->{$data->{itemnotforloan}}->{lib} = $data->{notforloanvalue}; >+ $av_cache->{$data->{frameworkcode}}->{'items.notforloan'}->{$data->{itemnotforloan}}->{opac_description} = $data->{notforloanvalueopac}; >+ } > # get restricted status and description if applicable >- $descriptions = Koha::AuthorisedValues->get_description_by_koha_field({frameworkcode => $data->{frameworkcode}, kohafield => 'items.restricted', authorised_value => $data->{restricted} }); >- $data->{restrictedvalue} = $descriptions->{lib} // ''; >- $data->{restrictedvalueopac} = $descriptions->{opac_description} // ''; >- >+ if (exists $av_cache->{$data->{frameworkcode}}->{'items.restricted'}->{$data->{restricted}} ) { >+ $data->{restrictedvalue} = $av_cache->{$data->{frameworkcode}}->{'items.restricted'}->{$data->{restricted}}->{lib}; >+ $data->{restrictedvalueopac} = $av_cache->{$data->{frameworkcode}}->{'items.restricted'}->{$data->{restricted}}->{opac_description}; >+ }else{ >+ $descriptions = Koha::AuthorisedValues->get_description_by_koha_field({frameworkcode => $data->{frameworkcode}, kohafield => 'items.restricted', authorised_value => $data->{restricted} }); >+ $data->{restrictedvalue} = $descriptions->{lib} // ''; >+ $data->{restrictedvalueopac} = $descriptions->{opac_description} // ''; >+ $av_cache->{$data->{frameworkcode}}->{'items.restricted'}->{$data->{restricted}}->{lib} = $data->{restrictedvalue} ; >+ $av_cache->{$data->{frameworkcode}}->{'items.restricted'}->{$data->{restricted}}->{opac_description} = $data->{restrictedvalueopac}; >+ } > # my stack procedures >- $descriptions = Koha::AuthorisedValues->get_description_by_koha_field({frameworkcode => $data->{frameworkcode}, kohafield => 'items.stack', authorised_value => $data->{stack} }); >- $data->{stack} = $descriptions->{lib} // ''; >+ if (exists $av_cache->{$data->{frameworkcode}}->{'items.stack'}->{$data->{stack}} ) { >+ $data->{stack} = $av_cache->{$data->{frameworkcode}}->{'items.stack'}->{$data->{stack}}->{lib}; >+ }else{ >+ $descriptions = Koha::AuthorisedValues->get_description_by_koha_field({frameworkcode => $data->{frameworkcode}, kohafield => 'items.stack', authorised_value => $data->{stack} }); >+ $data->{stack} = $descriptions->{lib} // ''; >+ $av_cache->{$data->{frameworkcode}}->{'items.stack'}->{$data->{stack}}->{lib} = $data->{stack}; >+ } > > # Find the last 3 people who borrowed this item. > my $sth2 = $dbh->prepare("SELECT * FROM old_issues,borrowers >-- >2.25.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 26587
:
120298
|
120299
|
120300
|
120311
|
120401
|
120402
|
127411
|
128446
|
128470
|
128471