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

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

Return to bug 7679