Bugzilla – Attachment 96460 Details for
Bug 24185
'If all unavailable' state for 'on shelf holds' makes holds page very slow if there's a lot of items
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 24185: Make holds page faster - improved "if"
Bug-24185-Make-holds-page-faster---improved-if.patch (text/plain), 2.90 KB, created by
Andrii Nugged
on 2019-12-18 20:03:57 UTC
(
hide
)
Description:
Bug 24185: Make holds page faster - improved "if"
Filename:
MIME Type:
Creator:
Andrii Nugged
Created:
2019-12-18 20:03:57 UTC
Size:
2.90 KB
patch
obsolete
>From 78b7094b8d96f36d57ee4ce53254af4683074dae Mon Sep 17 00:00:00 2001 >From: Andrew Nugged <nugged@gmail.com> >Date: Sat, 7 Dec 2019 14:37:58 +0200 >Subject: [PATCH] Bug 24185: Make holds page faster - improved "if" > >`$can_item_be_reserved eq 'OK'` moved in `&&` before `IsAvailableForItemLevelRequest` >to cut away with static known values before calling to more resource consuming subroutine. >--- > C4/Reserves.pm | 17 ++++++++++++++--- > reserve/request.pl | 2 +- > 2 files changed, 15 insertions(+), 4 deletions(-) > >diff --git a/C4/Reserves.pm b/C4/Reserves.pm >index 7a3785724a..ed9f47c1b6 100644 >--- a/C4/Reserves.pm >+++ b/C4/Reserves.pm >@@ -1188,7 +1188,12 @@ and canreservefromotherbranches. > =cut > > sub IsAvailableForItemLevelRequest { >- my ( $item, $patron, $pickup_branchcode ) = @_; >+ my $item = shift; >+ my $patron = shift; >+ my $pickup_branchcode = shift; >+ # items_any_available is precalculated status passed from request.pl when set of items >+ # looped outside of IsAvailableForItemLevelRequest to avoid nested loops: >+ my $items_any_available = shift; > > my $dbh = C4::Context->dbh; > # must check the notforloan setting of the itemtype >@@ -1205,8 +1210,6 @@ sub IsAvailableForItemLevelRequest { > $item->withdrawn || > ($item->damaged && !C4::Context->preference('AllowHoldsOnDamagedItems')); > >- my $on_shelf_holds = Koha::IssuingRules->get_onshelfholds_policy( { item => $item, patron => $patron } ); >- > if ($pickup_branchcode) { > my $destination = Koha::Libraries->find($pickup_branchcode); > return 0 unless $destination; >@@ -1214,9 +1217,17 @@ sub IsAvailableForItemLevelRequest { > return 0 unless $item->can_be_transferred( { to => $destination } ); > } > >+ my $on_shelf_holds = Koha::IssuingRules->get_onshelfholds_policy( { item => $item, patron => $patron } ); >+ > if ( $on_shelf_holds == 1 ) { > return 1; > } elsif ( $on_shelf_holds == 2 ) { >+ >+ # if we have this param predefined from outer caller sub, we just need >+ # to return it, so we saving from having loop inside other loop: >+ return $items_any_available ? 0 : 1 >+ if defined $items_any_available; >+ > my @items = > Koha::Items->search( { biblionumber => $item->biblionumber } ); > >diff --git a/reserve/request.pl b/reserve/request.pl >index 4f80b8d5b9..dc345900dc 100755 >--- a/reserve/request.pl >+++ b/reserve/request.pl >@@ -556,8 +556,8 @@ foreach my $biblionumber (@biblionumbers) { > if ( > !$item->{cantreserve} > && !$exceeded_maxreserves >- && IsAvailableForItemLevelRequest($item_object, $patron) > && $can_item_be_reserved eq 'OK' >+ && IsAvailableForItemLevelRequest($item_object, $patron) > ) > { > $item->{available} = 1; >-- >2.17.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 24185
:
96079
|
96080
|
96151
|
96354
|
96460
|
96461
|
96464
|
96491
|
96492
|
96493
|
96500
|
97375
|
97376
|
97377
|
97378
|
101355
|
101356
|
101357
|
101358
|
101607
|
101608
|
101609
|
101611
|
101613
|
101614
|
101615
|
101616