Bugzilla – Attachment 130527 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: Consolidate querycoutn code and only check if needed
Bug-30085-Consolidate-querycoutn-code-and-only-che.patch (text/plain), 4.05 KB, created by
Nick Clemens (kidclamp)
on 2022-02-11 20:00:21 UTC
(
hide
)
Description:
Bug 30085: Consolidate querycoutn code and only check if needed
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2022-02-11 20:00:21 UTC
Size:
4.05 KB
patch
obsolete
>From e8de08bce46af416031e16088d3b5fa352599aa6 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Fri, 11 Feb 2022 19:49:49 +0000 >Subject: [PATCH] Bug 30085: Consolidate querycoutn code and only check if > needed > >Similar to first patch, move a count only conditionally used into >the conditional > >This could be updated to use DBIC, but the itemtype conditionals >add complexity >--- > C4/Reserves.pm | 72 ++++++++++++++++++++++++-------------------------- > 1 file changed, 35 insertions(+), 37 deletions(-) > >diff --git a/C4/Reserves.pm b/C4/Reserves.pm >index 697aa3cd20..9eb9a35fed 100644 >--- a/C4/Reserves.pm >+++ b/C4/Reserves.pm >@@ -412,15 +412,6 @@ sub CanItemBeReserved { > > my $controlbranch = C4::Context->preference('ReservesControlBranch'); > >- my $querycount = q{ >- SELECT count(*) AS count >- FROM reserves >- LEFT JOIN items USING (itemnumber) >- LEFT JOIN biblioitems ON (reserves.biblionumber=biblioitems.biblionumber) >- LEFT JOIN borrowers USING (borrowernumber) >- WHERE borrowernumber = ? >- }; >- > my $reserves_control_branch; > my $branchfield = "reserves.branchcode"; > >@@ -482,39 +473,46 @@ sub CanItemBeReserved { > return { status => 'tooManyReservesToday', limit => $holds_per_day } if $today_holds->count() >= $holds_per_day; > } > >- # we retrieve count >- >- $querycount .= "AND ( $branchfield = ? OR $branchfield IS NULL )"; >- >- # If using item-level itypes, fall back to the record >- # level itemtype if the hold has no associated item >- $querycount .= >- C4::Context->preference('item-level_itypes') >- ? " AND COALESCE( items.itype, biblioitems.itemtype ) = ?" >- : " AND biblioitems.itemtype = ?" >- if defined $ruleitemtype; >- >- my $sthcount = $dbh->prepare($querycount); >- >- if ( defined $ruleitemtype ) { >- $sthcount->execute( $patron->borrowernumber, $reserves_control_branch, $ruleitemtype ); >- } >- else { >- $sthcount->execute( $patron->borrowernumber, $reserves_control_branch ); >- } >- >- my $reservecount = "0"; >- if ( my $rowcount = $sthcount->fetchrow_hashref() ) { >- $reservecount = $rowcount->{count}; >- } >- > # we check if it's ok or not > if ( defined $allowedreserves && $allowedreserves ne '' ){ > if( $allowedreserves == 0 ){ > return { status => 'noReservesAllowed' }; > } >- if ( !$params->{ignore_hold_counts} && $reservecount >= $allowedreserves ) { >- return { status => 'tooManyReserves', limit => $allowedreserves }; >+ if ( !$params->{ignore_hold_counts} ) { >+ # we retrieve count >+ my $querycount = q{ >+ SELECT count(*) AS count >+ FROM reserves >+ LEFT JOIN items USING (itemnumber) >+ LEFT JOIN biblioitems ON (reserves.biblionumber=biblioitems.biblionumber) >+ LEFT JOIN borrowers USING (borrowernumber) >+ WHERE borrowernumber = ? >+ }; >+ $querycount .= "AND ( $branchfield = ? OR $branchfield IS NULL )"; >+ >+ # If using item-level itypes, fall back to the record >+ # level itemtype if the hold has no associated item >+ $querycount .= >+ C4::Context->preference('item-level_itypes') >+ ? " AND COALESCE( items.itype, biblioitems.itemtype ) = ?" >+ : " AND biblioitems.itemtype = ?" >+ if defined $ruleitemtype; >+ >+ my $sthcount = $dbh->prepare($querycount); >+ >+ if ( defined $ruleitemtype ) { >+ $sthcount->execute( $patron->borrowernumber, $reserves_control_branch, $ruleitemtype ); >+ } >+ else { >+ $sthcount->execute( $patron->borrowernumber, $reserves_control_branch ); >+ } >+ >+ my $reservecount = "0"; >+ if ( my $rowcount = $sthcount->fetchrow_hashref() ) { >+ $reservecount = $rowcount->{count}; >+ } >+ >+ return { status => 'tooManyReserves', limit => $allowedreserves } if $reservecount >= $allowedreserves; > } > } > >-- >2.30.2
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