Bugzilla – Attachment 130829 Details for
Bug 30085
Improve performance of CanItemBeReserved
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 30085: Reduce scope of holds count / today holds count
Bug-30085-Reduce-scope-of-holds-count--today-holds.patch (text/plain), 2.90 KB, created by
Martin Renvoize (ashimema)
on 2022-02-18 12:34:06 UTC
(
hide
)
Description:
Bug 30085: Reduce scope of holds count / today holds count
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2022-02-18 12:34:06 UTC
Size:
2.90 KB
patch
obsolete
>From d278eca35aa6d0ba9c3baae2b4b9843504abba06 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Fri, 11 Feb 2022 19:21:22 +0000 >Subject: [PATCH] Bug 30085: Reduce scope of holds count / today holds count > >We retrieve two counts that are only needed if rules for hold limits are defined. >The DB counts should only be fetched once the rules are confirmed to exist > >Further improvement would be possiblke by allowing them to be passed in (or cached?) >from CanBookBeReserved as they rely only on patron/biblionumber and not item specific information > >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > C4/Reserves.pm | 31 ++++++++++++++----------------- > 1 file changed, 14 insertions(+), 17 deletions(-) > >diff --git a/C4/Reserves.pm b/C4/Reserves.pm >index f780fa5aa4..9b39130e0e 100644 >--- a/C4/Reserves.pm >+++ b/C4/Reserves.pm >@@ -458,31 +458,28 @@ sub CanItemBeReserved { > my $holds_per_record = $rights->{holds_per_record} // 1; > my $holds_per_day = $rights->{holds_per_day}; > >- my $search_params = { >- borrowernumber => $patron->borrowernumber, >- biblionumber => $item->biblionumber, >- }; >- $search_params->{found} = undef if $params->{ignore_found_holds}; >- >- my $holds = Koha::Holds->search($search_params); > if ( defined $holds_per_record && $holds_per_record ne '' ){ > if ( $holds_per_record == 0 ) { > return { status => "noReservesAllowed" }; > } >- if ( !$params->{ignore_hold_counts} && $holds->count() >= $holds_per_record ) { >- return { status => "tooManyHoldsForThisRecord", limit => $holds_per_record }; >+ if ( !$params->{ignore_hold_counts} ) { >+ my $search_params = { >+ borrowernumber => $patron->borrowernumber, >+ biblionumber => $item->biblionumber, >+ }; >+ $search_params->{found} = undef if $params->{ignore_found_holds}; >+ my $holds = Koha::Holds->search($search_params); >+ return { status => "tooManyHoldsForThisRecord", limit => $holds_per_record } if $holds->count() >= $holds_per_record; > } > } > >- my $today_holds = Koha::Holds->search({ >- borrowernumber => $patron->borrowernumber, >- reservedate => dt_from_string->date >- }); >- >- if (!$params->{ignore_hold_counts} && defined $holds_per_day && $holds_per_day ne '' >- && $today_holds->count() >= $holds_per_day ) >+ if (!$params->{ignore_hold_counts} && defined $holds_per_day && $holds_per_day ne '') > { >- return { status => 'tooManyReservesToday', limit => $holds_per_day }; >+ my $today_holds = Koha::Holds->search({ >+ borrowernumber => $patron->borrowernumber, >+ reservedate => dt_from_string->date >+ }); >+ return { status => 'tooManyReservesToday', limit => $holds_per_day } if $today_holds->count() >= $holds_per_day; > } > > # we retrieve count >-- >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 30085
:
130525
|
130526
|
130527
|
130528
|
130829
|
130830
|
130831
|
130832
|
130856
|
130857
|
130858
|
130859
|
138058