Bugzilla – Attachment 109850 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), 4.81 KB, created by
Fridolin Somers
on 2020-09-10 13:26:16 UTC
(
hide
)
Description:
Bug 26424: Better performance of svc/checkouts
Filename:
MIME Type:
Creator:
Fridolin Somers
Created:
2020-09-10 13:26:16 UTC
Size:
4.81 KB
patch
obsolete
>From d1c9437ef2c0ca7e72eee63b638f3e268079f6e3 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. > >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 and check info are the same : >record level item type, item type, location, collection, lost, damaged >--- > svc/checkouts | 34 ++++++++++++++++++++-------------- > 1 file changed, 20 insertions(+), 14 deletions(-) > >diff --git a/svc/checkouts b/svc/checkouts >index fa470b3a2a..c93cb65647 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,34 @@ 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 = $itemtypes->{ $c->{itype} } if $c->{itype}; >+ my $recordtype = $itemtypes->{ $c->{itemtype} } if $c->{itemtype}; >+ my $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 +202,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.27.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