View | Details | Raw Unified | Return to bug 7683
Collapse All | Expand All

(-)a/reports/issues_stats.pl (-11 / +26 lines)
Lines 472-480 sub calculate { Link Here
472
    foreach my $row (@loopline) {
472
    foreach my $row (@loopline) {
473
        foreach my $col (@loopcol) {
473
        foreach my $col (@loopcol) {
474
            $debug and warn " init table : $row->{rowtitle} ( $row->{rowtitle_display} ) / $col->{coltitle} ( $col->{coltitle_display} )  ";
474
            $debug and warn " init table : $row->{rowtitle} ( $row->{rowtitle_display} ) / $col->{coltitle} ( $col->{coltitle_display} )  ";
475
            $table{ $row->{rowtitle} }->{ $col->{coltitle} } = 0;
475
            table_set(\%table, $row->{rowtitle}, $col->{coltitle}, 0);
476
        }
476
        }
477
        $table{ $row->{rowtitle} }->{totalrow} = 0;
477
        table_set(\%table, $row->{rowtitle}, 'totalrow', 0);
478
    }
478
    }
479
479
480
    # preparing calculation
480
    # preparing calculation
Lines 578-591 sub calculate { Link Here
578
        ($debug) and warn "filling table $row / $col / $value ";
578
        ($debug) and warn "filling table $row / $col / $value ";
579
        unless ( defined $col ) {
579
        unless ( defined $col ) {
580
            $emptycol = 1;
580
            $emptycol = 1;
581
            $col      = "zzEMPTY";
582
        }
581
        }
583
        unless ( defined $row ) {
582
        unless ( defined $row ) {
584
            $emptyrow = 1;
583
            $emptyrow = 1;
585
            $row      = "zzEMPTY";
586
        }
584
        }
587
        $table{$row}->{$col}     += $value;
585
        table_inc(\%table, $row, $col, $value);
588
        $table{$row}->{totalrow} += $value;
586
        table_inc(\%table, $row, 'totalrow', $value);
589
        $grantotal               += $value;
587
        $grantotal               += $value;
590
    }
588
    }
591
    push @loopcol,  { coltitle => "NULL", coltitle_display => 'NULL' } if ($emptycol);
589
    push @loopcol,  { coltitle => "NULL", coltitle_display => 'NULL' } if ($emptycol);
Lines 597-603 sub calculate { Link Here
597
        #@loopcol ensures the order for columns is common with column titles
595
        #@loopcol ensures the order for columns is common with column titles
598
        # and the number matches the number of columns
596
        # and the number matches the number of columns
599
        foreach my $col (@loopcol) {
597
        foreach my $col (@loopcol) {
600
            my $value = $table{ null_to_zzempty( $row->{rowtitle} ) }->{ null_to_zzempty( $col->{coltitle} ) };
598
            my $value = table_get(\%table, $row->{rowtitle}, $col->{coltitle});
601
            push @loopcell, { value => $value };
599
            push @loopcell, { value => $value };
602
        }
600
        }
603
        my $rowtitle = ( $row->{rowtitle} eq "NULL" ) ? "zzEMPTY" : $row->{rowtitle};
601
        my $rowtitle = ( $row->{rowtitle} eq "NULL" ) ? "zzEMPTY" : $row->{rowtitle};
Lines 605-618 sub calculate { Link Here
605
          { 'rowtitle_display' => $row->{rowtitle_display},
603
          { 'rowtitle_display' => $row->{rowtitle_display},
606
            'rowtitle'         => $rowtitle,
604
            'rowtitle'         => $rowtitle,
607
            'loopcell'         => \@loopcell,
605
            'loopcell'         => \@loopcell,
608
            'totalrow'         => $table{$rowtitle}->{totalrow}
606
            'totalrow'         => table_get(\%table, $rowtitle, 'totalrow'),
609
          };
607
          };
610
    }
608
    }
611
    for my $col (@loopcol) {
609
    for my $col (@loopcol) {
612
        my $total = 0;
610
        my $total = 0;
613
        foreach my $row (@looprow) {
611
        foreach my $row (@looprow) {
614
            $total += $table{ null_to_zzempty( $row->{rowtitle} ) }->{ null_to_zzempty( $col->{coltitle} ) };
612
            $total += table_get(\%table, $row->{rowtitle}, $col->{coltitle});
615
            $debug and warn "value added " . $table{ $row->{rowtitle} }->{ $col->{coltitle} } . "for line " . $row->{rowtitle};
613
            $debug and warn "value added " . table_get(\%table, $row->{rowtitle}, $col->{coltitle}) . "for line " . $row->{rowtitle};
616
        }
614
        }
617
        push @loopfooter, { 'totalcol' => $total };
615
        push @loopfooter, { 'totalcol' => $total };
618
    }
616
    }
Lines 639-642 sub null_to_zzempty ($) { Link Here
639
	return $string;		# else return the valid value
637
	return $string;		# else return the valid value
640
}
638
}
641
639
640
sub table_set {
641
    my ($table, $row, $col, $val) = @_;
642
643
    $table->{ null_to_zzempty(lc($row)) }->{ null_to_zzempty(lc($col)) } = $val;
644
}
645
646
sub table_get {
647
    my ($table, $row, $col) = @_;
648
649
    return $table->{ null_to_zzempty(lc($row)) }->{ null_to_zzempty(lc($col)) };
650
}
651
652
sub table_inc {
653
    my ($table, $row, $col, $inc) = @_;
654
655
    $table->{ null_to_zzempty(lc($row)) }->{ null_to_zzempty(lc($col)) } += $inc;
656
}
657
642
1;
658
1;
643
- 

Return to bug 7683