Bugzilla – Attachment 105705 Details for
Bug 25683
update_patron_categories.pl should recognize no fine history = 0 outstanding fines
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 25683: Fix grouping of results
Bug-25683-Fix-grouping-of-results.patch (text/plain), 3.03 KB, created by
David Nind
on 2020-06-10 17:26:10 UTC
(
hide
)
Description:
Bug 25683: Fix grouping of results
Filename:
MIME Type:
Creator:
David Nind
Created:
2020-06-10 17:26:10 UTC
Size:
3.03 KB
patch
obsolete
>From e5d77154ac4ea5f903095233e97bf23477606ba8 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Wed, 10 Jun 2020 12:26:06 +0000 >Subject: [PATCH] Bug 25683: Fix grouping of results > >DBIX doesn't seem to work as I expected - if trying to group by we can only >get the columns we grouped by, otherwise the queries are much more complicated >and come out wrong > >This patch removes the 'amountoutstanding' from the query. Note that we do return patron >object, however, to access all the columns we must discard_changes (or refetch) > >Also fixes a typo 'verbosse' > >To test: >1 - charge a $1 fine to a patron >2 - pay off the fine >3 - perl misc/cronjobs/update_patrons_category.pl -f J -t J -fu=5 -v >4 - Note the patron is returned twice >5 - export DBIC_TRACE=1 >6 - repeat 3 - view the SQL query and see how odd it is >7 - Apply this patch >8 - repeat 3 - simpler query >9 - patron returned only once > >Signed-off-by: David Nind <david@davidnind.com> >--- > Koha/Patrons.pm | 2 +- > misc/cronjobs/update_patrons_category.pl | 9 +++++---- > 2 files changed, 6 insertions(+), 5 deletions(-) > >diff --git a/Koha/Patrons.pm b/Koha/Patrons.pm >index 6d45751a41..c20a6599bf 100644 >--- a/Koha/Patrons.pm >+++ b/Koha/Patrons.pm >@@ -397,7 +397,7 @@ sub search_patrons_to_update_category { > } > if ($params->{fine_min} || $params->{fine_max}) { > $query{join} = ["accountlines"]; >- $query{select} = ["borrowernumber", "accountlines.amountoutstanding" ]; >+ $query{columns} = ["borrowernumber"]; > $query{group_by} = ["borrowernumber"]; > $query{having} = \['IFNULL(sum(accountlines.amountoutstanding),0) <= ?',$params->{fine_max}] if defined $params->{fine_max}; > $query{having} = \['IFNULL(sum(accountlines.amountoutstanding),0) >= ?',$params->{fine_min}] if defined $params->{fine_min}; >diff --git a/misc/cronjobs/update_patrons_category.pl b/misc/cronjobs/update_patrons_category.pl >index 3de4822b3d..207f9b6cd9 100644 >--- a/misc/cronjobs/update_patrons_category.pl >+++ b/misc/cronjobs/update_patrons_category.pl >@@ -74,7 +74,7 @@ Print a brief help message and exits. > > Prints the manual page and exits. > >-=item B<--verbosse | -v> >+=item B<--verbose | -v> > > Verbose. Without this flag set, only fatal errors are reported. > >@@ -248,17 +248,18 @@ my $target_patrons = Koha::Patrons->search(\%params)->search_patrons_to_update_c > fine_max => $fine_max, > } > ); >+ > my $patrons_found = $target_patrons->count; > my $actually_updated = 0; > my $testdisplay = $doit ? "" : "WOULD HAVE "; > if ($verbose) { > while ( my $target_patron = $target_patrons->next() ) { >- my $target = Koha::Patrons->find( $target_patron->borrowernumber ); >+ $target_patron->discard_changes(); > $verbose > and print $testdisplay > . "Updated " >- . $target->firstname . " " >- . $target->surname >+ . $target_patron->firstname() . " " >+ . $target_patron->surname() > . " from $fromcat to $tocat\n"; > } > $target_patrons->reset; >-- >2.11.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 25683
:
105620
|
105660
|
105662
|
105690
|
105704
|
105705
|
107792
|
107850
|
107851
|
107852