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

(-)a/reports/issues_stats.pl (-11 / +26 lines)
Lines 466-474 sub calculate { Link Here
466
    foreach my $row (@loopline) {
466
    foreach my $row (@loopline) {
467
        foreach my $col (@loopcol) {
467
        foreach my $col (@loopcol) {
468
            $debug and warn " init table : $row->{rowtitle} ( $row->{rowtitle_display} ) / $col->{coltitle} ( $col->{coltitle_display} )  ";
468
            $debug and warn " init table : $row->{rowtitle} ( $row->{rowtitle_display} ) / $col->{coltitle} ( $col->{coltitle_display} )  ";
469
            $table{ $row->{rowtitle} }->{ $col->{coltitle} } = 0;
469
            table_set(\%table, $row->{rowtitle}, $col->{coltitle}, 0);
470
        }
470
        }
471
        $table{ $row->{rowtitle} }->{totalrow} = 0;
471
        table_set(\%table, $row->{rowtitle}, 'totalrow', 0);
472
    }
472
    }
473
473
474
    # preparing calculation
474
    # preparing calculation
Lines 572-585 sub calculate { Link Here
572
        ($debug) and warn "filling table $row / $col / $value ";
572
        ($debug) and warn "filling table $row / $col / $value ";
573
        unless ( defined $col ) {
573
        unless ( defined $col ) {
574
            $emptycol = 1;
574
            $emptycol = 1;
575
            $col      = "zzEMPTY";
576
        }
575
        }
577
        unless ( defined $row ) {
576
        unless ( defined $row ) {
578
            $emptyrow = 1;
577
            $emptyrow = 1;
579
            $row      = "zzEMPTY";
580
        }
578
        }
581
        $table{$row}->{$col}     += $value;
579
        table_inc(\%table, $row, $col, $value);
582
        $table{$row}->{totalrow} += $value;
580
        table_inc(\%table, $row, 'totalrow', $value);
583
        $grantotal               += $value;
581
        $grantotal               += $value;
584
    }
582
    }
585
    push @loopcol,  { coltitle => "NULL", coltitle_display => 'NULL' } if ($emptycol);
583
    push @loopcol,  { coltitle => "NULL", coltitle_display => 'NULL' } if ($emptycol);
Lines 591-597 sub calculate { Link Here
591
        #@loopcol ensures the order for columns is common with column titles
589
        #@loopcol ensures the order for columns is common with column titles
592
        # and the number matches the number of columns
590
        # and the number matches the number of columns
593
        foreach my $col (@loopcol) {
591
        foreach my $col (@loopcol) {
594
            my $value = $table{ null_to_zzempty( $row->{rowtitle} ) }->{ null_to_zzempty( $col->{coltitle} ) };
592
            my $value = table_get(\%table, $row->{rowtitle}, $col->{coltitle});
595
            push @loopcell, { value => $value };
593
            push @loopcell, { value => $value };
596
        }
594
        }
597
        my $rowtitle = ( $row->{rowtitle} eq "NULL" ) ? "zzEMPTY" : $row->{rowtitle};
595
        my $rowtitle = ( $row->{rowtitle} eq "NULL" ) ? "zzEMPTY" : $row->{rowtitle};
Lines 599-612 sub calculate { Link Here
599
          { 'rowtitle_display' => $row->{rowtitle_display},
597
          { 'rowtitle_display' => $row->{rowtitle_display},
600
            'rowtitle'         => $rowtitle,
598
            'rowtitle'         => $rowtitle,
601
            'loopcell'         => \@loopcell,
599
            'loopcell'         => \@loopcell,
602
            'totalrow'         => $table{$rowtitle}->{totalrow}
600
            'totalrow'         => table_get(\%table, $rowtitle, 'totalrow'),
603
          };
601
          };
604
    }
602
    }
605
    for my $col (@loopcol) {
603
    for my $col (@loopcol) {
606
        my $total = 0;
604
        my $total = 0;
607
        foreach my $row (@looprow) {
605
        foreach my $row (@looprow) {
608
            $total += $table{ null_to_zzempty( $row->{rowtitle} ) }->{ null_to_zzempty( $col->{coltitle} ) };
606
            $total += table_get(\%table, $row->{rowtitle}, $col->{coltitle});
609
            $debug and warn "value added " . $table{ $row->{rowtitle} }->{ $col->{coltitle} } . "for line " . $row->{rowtitle};
607
            $debug and warn "value added " . table_get(\%table, $row->{rowtitle}, $col->{coltitle}) . "for line " . $row->{rowtitle};
610
        }
608
        }
611
        push @loopfooter, { 'totalcol' => $total };
609
        push @loopfooter, { 'totalcol' => $total };
612
    }
610
    }
Lines 633-636 sub null_to_zzempty ($) { Link Here
633
	return $string;		# else return the valid value
631
	return $string;		# else return the valid value
634
}
632
}
635
633
634
sub table_set {
635
    my ($table, $row, $col, $val) = @_;
636
637
    $table->{ null_to_zzempty(lc($row)) }->{ null_to_zzempty(lc($col)) } = $val;
638
}
639
640
sub table_get {
641
    my ($table, $row, $col) = @_;
642
643
    return $table->{ null_to_zzempty(lc($row)) }->{ null_to_zzempty(lc($col)) };
644
}
645
646
sub table_inc {
647
    my ($table, $row, $col, $inc) = @_;
648
649
    $table->{ null_to_zzempty(lc($row)) }->{ null_to_zzempty(lc($col)) } += $inc;
650
}
651
636
1;
652
1;
637
- 

Return to bug 7679