Bugzilla – Attachment 37267 Details for
Bug 13914
The holds statistics report returns random data
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 13914: Holds statistics report should add values from reserves and old_reserves
Bug-13914-Holds-statistics-report-should-add-value.patch (text/plain), 3.12 KB, created by
Jonathan Druart
on 2015-03-26 12:33:09 UTC
(
hide
)
Description:
Bug 13914: Holds statistics report should add values from reserves and old_reserves
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2015-03-26 12:33:09 UTC
Size:
3.12 KB
patch
obsolete
>From 5b663bf17415f04e515a387b6afbf50b4ffdf4e7 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@biblibre.com> >Date: Thu, 26 Mar 2015 13:22:06 +0100 >Subject: [PATCH] Bug 13914: Holds statistics report should add values from > reserves and old_reserves >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >And not pick one randomly... > >To reproduce: >1/ Go on Reports ⺠Holds statistics > >2/ Fill the form with: >Hold status: All checked (Asked Processing Waiting Satisfied Cancelled) >Hold Date From 01/01/2014 To 31/01/2014 > >Pickup library => empty >Holding library => empty >Home library => empty > >Row is "Hold status", Column is "Pickup library". > >3/ Submit! > >4/ Look at the results > >5/ Restart mysql > >6/ Ctrl+R to resubmit the form > >7/ Look at the results > >The generated query looks like ( SELECT stuffs FROM reserves ) UNION ( >SELECT stuffs FROM old_reserves ) >It returns something like: >+------+---------------+-------------+ >| line | col | calculation | >+------+---------------+-------------+ >| 1 | BRANCHCODE1 | 1 | < from the reserves table >| 1 | BRANCHCODE1 | 11 | < from the old_reserves table >| 1 | BRANCHCODE2 | 2 | >| 1 | BRANCHCODE2 | 22 | >| 2 | BRANCHCODE1 | 4 | >| 2 | BRANCHCODE1 | 44 | >| 2 | BRANCHCODE2 | 5 | >| 2 | BRANCHCODE2 | 55 | >+------+---------------+-------------+ > >The screen will display 1 OR 11 for the BRANCHCODE1 line 1. >Since ( line, col ) is not uniq, fetchall_hashref (l.280) was not a good >idea here. >This patch replaces it with fetchall_arrayref, reconstruct the variables >used later and add the values from reserves and old_reserves. > >Test plan: >Confirm that the results are now relevant. >--- > reports/reserves_stats.pl | 23 +++++++++++++---------- > 1 file changed, 13 insertions(+), 10 deletions(-) > >diff --git a/reports/reserves_stats.pl b/reports/reserves_stats.pl >index df8d648..b798862 100755 >--- a/reports/reserves_stats.pl >+++ b/reports/reserves_stats.pl >@@ -275,17 +275,20 @@ sub calculate { > @sqlparams=(@sqlparams,@sqlorparams); > $dbcalc->execute(@sqlparams,@sqlparams); > my ($emptycol,$emptyrow); >- my $data = $dbcalc->fetchall_hashref([qw(line col)]); >- my %cols_hash; >- foreach my $row (keys %$data){ >- push @loopline, $row; >- foreach my $col (keys %{$$data{$row}}){ >- $$data{$row}{totalrow}+=$$data{$row}{$col}{calculation}; >- $grantotal+=$$data{$row}{$col}{calculation}; >- $cols_hash{$col}=1 ; >- } >- } > my $urlbase="do_it=1&".join("&",map{"filter_$_=$$filters_hashref{$_}"} keys %$filters_hashref); >+ >+ my $results = $dbcalc->fetchall_arrayref({}); >+ my %cols_hash; >+ my $data; >+ foreach my $r (@$results){ >+ my $row = $r->{line}; >+ $data->{$row}{$r->{col}}{calculation} += $r->{calculation}; >+ $data->{$row}{totalrow} += $r->{calculation}; >+ $grantotal += $r->{calculation}; >+ $cols_hash{$r->{col}}=1 ; >+ } >+ @loopline = keys $data; >+ > foreach my $row (sort @loopline) { > my @loopcell; > #@loopcol ensures the order for columns is common with column titles >-- >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 13914
:
37267
|
54271
|
54279
|
55173
|
55521