Bugzilla – Attachment 42167 Details for
Bug 14702
Refactor GetReserveFee
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 14702: [QA Follow-up] More readable variable names, less queries
Bug-14702-QA-Follow-up-More-readable-variable-name.patch (text/plain), 2.51 KB, created by
Jonathan Druart
on 2015-09-01 14:31:26 UTC
(
hide
)
Description:
Bug 14702: [QA Follow-up] More readable variable names, less queries
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2015-09-01 14:31:26 UTC
Size:
2.51 KB
patch
obsolete
>From a2c01db9404a4962670c6fc432a6894fe6fdeec0 Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Tue, 1 Sep 2015 15:39:16 +0200 >Subject: [PATCH] Bug 14702: [QA Follow-up] More readable variable names, less > queries > >The names are much better now :) >Combined the queries for items and issues. >Only check the number of holds when needed. > >Test plan: >Verify the changes here by running the unit test again. > >Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >--- > C4/Reserves.pm | 22 +++++++++++++++++----- > 1 file changed, 17 insertions(+), 5 deletions(-) > >diff --git a/C4/Reserves.pm b/C4/Reserves.pm >index e8638a9..6120bbc 100644 >--- a/C4/Reserves.pm >+++ b/C4/Reserves.pm >@@ -672,18 +672,30 @@ sub GetReserveFee { > my $borquery = qq{ > SELECT reservefee FROM borrowers LEFT JOIN categories ON borrowers.categorycode = categories.categorycode WHERE borrowernumber = ? > }; >+ my $issue_qry = qq{ >+SELECT COUNT(*) FROM items >+LEFT JOIN issues USING (itemnumber) >+WHERE items.biblionumber=? AND issues.issue_id IS NULL >+ }; >+ my $holds_qry = qq{ >+SELECT COUNT(*) FROM reserves WHERE biblionumber=? AND borrowernumber<>? >+ }; > > my $dbh = C4::Context->dbh; > my ( $fee ) = $dbh->selectrow_array( $borquery, undef, ($borrowernumber) ); > if( $fee && $fee > 0 ) { > # This is a reconstruction of the old code: >- # Calculate number of items, items issued and holds >- my ( $cnt1 ) = $dbh->selectrow_array( "SELECT COUNT(*) FROM items WHERE biblionumber=?", undef, ( $biblionumber ) ); >- my ( $cnt2 ) = $dbh->selectrow_array( "SELECT COUNT(*) FROM issues LEFT JOIN items USING (itemnumber) WHERE biblionumber=?", undef, ( $biblionumber )); >- my ( $cnt3 ) = $dbh->selectrow_array( "SELECT COUNT(*) FROM reserves WHERE biblionumber=? AND borrowernumber<>?", undef, ( $biblionumber, $borrowernumber ) ); >+ # Compare number of items with items issued, and optionally check holds > # If not all items are issued and there are no holds: charge no fee > # NOTE: Lost, damaged, not-for-loan, etc. are just ignored here >- $fee = 0 if $cnt1 - $cnt2 > 0 && $cnt3 == 0; >+ my ( $notissued, $reserved ); >+ ( $notissued ) = $dbh->selectrow_array( $issue_qry, undef, >+ ( $biblionumber ) ); >+ if( $notissued ) { >+ ( $reserved ) = $dbh->selectrow_array( $holds_qry, undef, >+ ( $biblionumber, $borrowernumber ) ); >+ $fee = 0 if $reserved == 0; >+ } > } > return $fee; > } >-- >2.1.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 14702
:
41779
|
41780
|
41781
|
41853
|
41854
|
41856
|
41857
|
42005
|
42006
|
42015
|
42016
|
42017
|
42153
|
42154
|
42155
|
42156
|
42165
|
42166
|
42167
|
42191