Bugzilla – Attachment 110429 Details for
Bug 26424
Better performance of svc/checkouts
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 26424: Better performance of svc/checkouts
Bug-26424-Better-performance-of-svccheckouts.patch (text/plain), 5.37 KB, created by
Katrin Fischer
on 2020-09-20 17:35:00 UTC
(
hide
)
Description:
Bug 26424: Better performance of svc/checkouts
Filename:
MIME Type:
Creator:
Katrin Fischer
Created:
2020-09-20 17:35:00 UTC
Size:
5.37 KB
patch
obsolete
>From 0e01f98a15bb351e414d9a50c2bb9b6bda1f3338 Mon Sep 17 00:00:00 2001 >From: Fridolin Somers <fridolin.somers@biblibre.com> >Date: Thu, 10 Sep 2020 15:12:39 +0200 >Subject: [PATCH] Bug 26424: Better performance of svc/checkouts > >Ajax script svc/checkouts display checkouts of a patron. >For each item, it fetches a Koha::ItemType object and a Koha::AuthorisedValues object for location,ccode,lost and damaged. > >For performance on huge number of checkouts : >Item types should be fetch once before the loop. >authorised values should call Koha::AuthorisedValues->get_description_by_koha_field because it uses a cache. > >I've tested with Plack : >Without patch : >100 checkouts = 6 seconds >1000 checkouts = 60 seconds >With patch : >100 checkouts = 5 seconds >1000 checkouts = 44 seconds > >Patch also changes the fact that authorised value categories are no longer hardcoded LOC,CCODE,LOST and DAMAGED, they depend on default framework. >Like is doing Bug 26323. > >Test plan : >1) Dont apply patch >2) Use sql to define some items lost and damaged >3) Look at checkouts table on a patron with a lot of checkouts >4) Apply patch >5) Look at checkouts table again >6) Check infos are the same : record level item type, item type, location, collection, lost, damaged >7) Check infos are the same in "Number of checkouts by item type" > >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> > >Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> >--- > svc/checkouts | 36 ++++++++++++++++++++++-------------- > 1 file changed, 22 insertions(+), 14 deletions(-) > >diff --git a/svc/checkouts b/svc/checkouts >index fa470b3a2a..968388ae8d 100755 >--- a/svc/checkouts >+++ b/svc/checkouts >@@ -140,6 +140,8 @@ $sth->execute(@parameters); > my $item_level_itypes = C4::Context->preference('item-level_itypes'); > my $claims_returned_lost_value = C4::Context->preference('ClaimReturnedLostValue'); > >+my $itemtypes = { map { $_->{itemtype} => $_->{translated_description} } @{ Koha::ItemTypes->search_with_localization->unblessed } }; >+ > my @checkouts_today; > my @checkouts_previous; > while ( my $c = $sth->fetchrow_hashref() ) { >@@ -161,30 +163,36 @@ while ( my $c = $sth->fetchrow_hashref() ) { > my ( $renewals_count, $renewals_allowed, $renewals_remaining ) = > GetRenewCount( $c->{borrowernumber}, $c->{itemnumber} ); > >- my $type_for_stat = Koha::ItemTypes->find( $item_level_itypes ? $c->{itype} : $c->{itemtype} ); >- my $itemtype = Koha::ItemTypes->find( $c->{itype} ); >- my $recordtype = Koha::ItemTypes->find( $c->{itemtype} ); >+ my ( $itemtype, $recordtype, $type_for_stat ); >+ $itemtype = $itemtypes->{ $c->{itype} } if $c->{itype}; >+ $recordtype = $itemtypes->{ $c->{itemtype} } if $c->{itemtype}; >+ $type_for_stat = $item_level_itypes ? $itemtype : $recordtype; >+ > my $location; > if ( $c->{location} ) { >- my $av = Koha::AuthorisedValues->search({ category => 'LOC', authorised_value => $c->{location} }); >- $location = $av->count ? $av->next->lib : ''; >+ my $av = Koha::AuthorisedValues->get_description_by_koha_field( >+ { kohafield => 'items.location', authorised_value => $c->{location} } ); >+ $location = $av->{lib} ? $av->{lib} : ''; > } > my $collection; > if ( $c->{collection} ) { >- my $av = Koha::AuthorisedValues->search({ category => 'CCODE', authorised_value => $c->{collection} }); >- $collection = $av->count ? $av->next->lib : ''; >+ my $av = Koha::AuthorisedValues->get_description_by_koha_field( >+ { kohafield => 'items.ccode', authorised_value => $c->{collection} } ); >+ $collection = $av->{lib} ? $av->{lib} : ''; > } > my $lost; > my $claims_returned; > if ( $c->{itemlost} ) { >- my $av = Koha::AuthorisedValues->search({ category => 'LOST', authorised_value => $c->{itemlost} }); >- $lost = $av->count ? $av->next->lib : ''; >+ my $av = Koha::AuthorisedValues->get_description_by_koha_field( >+ { kohafield => 'items.itemlost', authorised_value => $c->{itemlost} } ); >+ $lost = $av->{lib} ? $av->{lib} : ''; > $claims_returned = $c->{itemlost} eq $claims_returned_lost_value; > } > my $damaged; > if ( $c->{damaged} ) { >- my $av = Koha::AuthorisedValues->search({ category => 'DAMAGED', authorised_value => $c->{damaged} }); >- $damaged = $av->count ? $av->next->lib : ''; >+ my $av = Koha::AuthorisedValues->get_description_by_koha_field( >+ { kohafield => 'items.damaged', authorised_value => $c->{damaged} } ); >+ $damaged = $av->{lib} ? $av->{lib} : ''; > } > my @subtitles = split(/ \| /, $c->{'subtitle'} // '' ); > my $checkout = { >@@ -196,9 +204,9 @@ while ( my $c = $sth->fetchrow_hashref() ) { > part_name => $c->{part_name} // '', > author => $c->{author}, > barcode => $c->{barcode}, >- type_for_stat => $type_for_stat ? $type_for_stat->translated_description : q{}, >- itemtype_description => $itemtype ? $itemtype->translated_description : q{}, >- recordtype_description => $recordtype ? $recordtype->translated_description : q{}, >+ type_for_stat => $type_for_stat || q{}, >+ itemtype_description => $itemtype || q{}, >+ recordtype_description => $recordtype || q{}, > collection => $collection, > location => $location, > homebranch => $c->{homebranch}, >-- >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 26424
:
109850
|
109851
|
109883
|
110209
|
110378
|
110379
| 110429