Bugzilla – Attachment 130856 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.98 KB, created by
Jonathan Druart
on 2022-02-18 14:32:01 UTC
(
hide
)
Description:
Bug 30085: Reduce scope of holds count / today holds count
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2022-02-18 14:32:01 UTC
Size:
2.98 KB
patch
obsolete
>From 6b8c2fe96bff700eac5275526f4004cae018a1ae 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> > >Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >--- > C4/Reserves.pm | 31 ++++++++++++++----------------- > 1 file changed, 14 insertions(+), 17 deletions(-) > >diff --git a/C4/Reserves.pm b/C4/Reserves.pm >index f780fa5aa49..9b39130e0e6 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.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 30085
:
130525
|
130526
|
130527
|
130528
|
130829
|
130830
|
130831
|
130832
| 130856 |
130857
|
130858
|
130859
|
138058