From 80c2c188ad0307d328c6d521d7952ee70600e15d Mon Sep 17 00:00:00 2001 From: Julian Maurice Date: Wed, 6 Nov 2013 08:47:13 +0100 Subject: [PATCH] Bug 7679: Group different case values in the same row/column --- reports/issues_stats.pl | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/reports/issues_stats.pl b/reports/issues_stats.pl index 284f556..cdb89a5 100755 --- a/reports/issues_stats.pl +++ b/reports/issues_stats.pl @@ -466,9 +466,9 @@ sub calculate { foreach my $row (@loopline) { foreach my $col (@loopcol) { $debug and warn " init table : $row->{rowtitle} ( $row->{rowtitle_display} ) / $col->{coltitle} ( $col->{coltitle_display} ) "; - $table{ $row->{rowtitle} }->{ $col->{coltitle} } = 0; + table_set(\%table, $row->{rowtitle}, $col->{coltitle}, 0); } - $table{ $row->{rowtitle} }->{totalrow} = 0; + table_set(\%table, $row->{rowtitle}, 'totalrow', 0); } # preparing calculation @@ -572,14 +572,12 @@ sub calculate { ($debug) and warn "filling table $row / $col / $value "; unless ( defined $col ) { $emptycol = 1; - $col = "zzEMPTY"; } unless ( defined $row ) { $emptyrow = 1; - $row = "zzEMPTY"; } - $table{$row}->{$col} += $value; - $table{$row}->{totalrow} += $value; + table_inc(\%table, $row, $col, $value); + table_inc(\%table, $row, 'totalrow', $value); $grantotal += $value; } push @loopcol, { coltitle => "NULL", coltitle_display => 'NULL' } if ($emptycol); @@ -591,7 +589,7 @@ sub calculate { #@loopcol ensures the order for columns is common with column titles # and the number matches the number of columns foreach my $col (@loopcol) { - my $value = $table{ null_to_zzempty( $row->{rowtitle} ) }->{ null_to_zzempty( $col->{coltitle} ) }; + my $value = table_get(\%table, $row->{rowtitle}, $col->{coltitle}); push @loopcell, { value => $value }; } my $rowtitle = ( $row->{rowtitle} eq "NULL" ) ? "zzEMPTY" : $row->{rowtitle}; @@ -599,14 +597,14 @@ sub calculate { { 'rowtitle_display' => $row->{rowtitle_display}, 'rowtitle' => $rowtitle, 'loopcell' => \@loopcell, - 'totalrow' => $table{$rowtitle}->{totalrow} + 'totalrow' => table_get(\%table, $rowtitle, 'totalrow'), }; } for my $col (@loopcol) { my $total = 0; foreach my $row (@looprow) { - $total += $table{ null_to_zzempty( $row->{rowtitle} ) }->{ null_to_zzempty( $col->{coltitle} ) }; - $debug and warn "value added " . $table{ $row->{rowtitle} }->{ $col->{coltitle} } . "for line " . $row->{rowtitle}; + $total += table_get(\%table, $row->{rowtitle}, $col->{coltitle}); + $debug and warn "value added " . table_get(\%table, $row->{rowtitle}, $col->{coltitle}) . "for line " . $row->{rowtitle}; } push @loopfooter, { 'totalcol' => $total }; } @@ -633,4 +631,22 @@ sub null_to_zzempty ($) { return $string; # else return the valid value } +sub table_set { + my ($table, $row, $col, $val) = @_; + + $table->{ null_to_zzempty(lc($row)) }->{ null_to_zzempty(lc($col)) } = $val; +} + +sub table_get { + my ($table, $row, $col) = @_; + + return $table->{ null_to_zzempty(lc($row)) }->{ null_to_zzempty(lc($col)) }; +} + +sub table_inc { + my ($table, $row, $col, $inc) = @_; + + $table->{ null_to_zzempty(lc($row)) }->{ null_to_zzempty(lc($col)) } += $inc; +} + 1; -- 2.1.4