Calculate totals over numeric columns
parent
a4f77c4340
commit
4b7a51efa8
|
@ -463,11 +463,12 @@ sub STATIC_COLUMNS
|
||||||
reporter_short => { title => 'Reporter Login' },
|
reporter_short => { title => 'Reporter Login' },
|
||||||
qa_contact_short => { title => 'QA Contact Login' },
|
qa_contact_short => { title => 'QA Contact Login' },
|
||||||
# FIXME save aggregated work_time in bugs table and search on it
|
# FIXME save aggregated work_time in bugs table and search on it
|
||||||
work_time => { name => $actual_time },
|
work_time => { name => $actual_time, numeric => 1 },
|
||||||
interval_time => { name => $actual_time, title => 'Period Worktime', noreports => 1 },
|
interval_time => { name => $actual_time, title => 'Period Worktime', noreports => 1, numeric => 1 },
|
||||||
percentage_complete => {
|
percentage_complete => {
|
||||||
name => "(CASE WHEN $actual_time + bugs.remaining_time = 0.0 THEN 0.0" .
|
name => "(CASE WHEN $actual_time + bugs.remaining_time = 0.0 THEN 0.0" .
|
||||||
" ELSE 100 * ($actual_time / ($actual_time + bugs.remaining_time)) END)",
|
" ELSE 100 * ($actual_time / ($actual_time + bugs.remaining_time)) END)",
|
||||||
|
numeric => 1,
|
||||||
},
|
},
|
||||||
'flagtypes.name' => {
|
'flagtypes.name' => {
|
||||||
name =>
|
name =>
|
||||||
|
@ -625,6 +626,10 @@ sub STATIC_COLUMNS
|
||||||
elsif ($bug_columns->{$id})
|
elsif ($bug_columns->{$id})
|
||||||
{
|
{
|
||||||
$columns->{$id}->{name} ||= "bugs.$id";
|
$columns->{$id}->{name} ||= "bugs.$id";
|
||||||
|
if ($field->type == FIELD_TYPE_NUMERIC)
|
||||||
|
{
|
||||||
|
$columns->{$id}->{numeric} = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
53
buglist.cgi
53
buglist.cgi
|
@ -707,22 +707,16 @@ $buglist_sth->execute();
|
||||||
|
|
||||||
# Retrieve the query results one row at a time and write the data into a list of Perl records.
|
# Retrieve the query results one row at a time and write the data into a list of Perl records.
|
||||||
|
|
||||||
# If we're doing time tracking, then keep totals for all bugs.
|
# Calculate totals
|
||||||
my $percentage_complete = 1 && grep { $_ eq 'percentage_complete' } @$displaycolumns;
|
my $total_info;
|
||||||
my $estimated_time = 1 && grep { $_ eq 'estimated_time' } @$displaycolumns;
|
for my $column (@$displaycolumns)
|
||||||
my $remaining_time = $percentage_complete || grep { $_ eq 'remaining_time' } @$displaycolumns;
|
{
|
||||||
my $work_time = $percentage_complete || grep { $_ eq 'work_time' } @$displaycolumns;
|
if (Bugzilla::Search->COLUMNS->{$column}->{numeric})
|
||||||
my $interval_time = $percentage_complete || grep { $_ eq 'interval_time' } @$displaycolumns;
|
{
|
||||||
|
$total_info ||= {};
|
||||||
my $time_info = {
|
$total_info->{$column} = 0;
|
||||||
estimated_time => 0,
|
}
|
||||||
remaining_time => 0,
|
}
|
||||||
work_time => 0,
|
|
||||||
percentage_complete => 0,
|
|
||||||
interval_time => 0, # CustIS Bug 68921
|
|
||||||
time_present => ($estimated_time || $remaining_time ||
|
|
||||||
$work_time || $percentage_complete || $interval_time),
|
|
||||||
};
|
|
||||||
|
|
||||||
my $bugowners = {};
|
my $bugowners = {};
|
||||||
my $bugproducts = {};
|
my $bugproducts = {};
|
||||||
|
@ -763,10 +757,10 @@ while (my @row = $buglist_sth->fetchrow_array())
|
||||||
push(@bugidlist, $bug->{bug_id});
|
push(@bugidlist, $bug->{bug_id});
|
||||||
|
|
||||||
# Compute time tracking info.
|
# Compute time tracking info.
|
||||||
$time_info->{estimated_time} += $bug->{estimated_time} if $estimated_time;
|
for my $column (keys %$total_info)
|
||||||
$time_info->{remaining_time} += $bug->{remaining_time} if $remaining_time;
|
{
|
||||||
$time_info->{work_time} += $bug->{work_time} if $work_time;
|
$total_info->{$column} += $bug->{$column} if $column ne 'percentage_complete';
|
||||||
$time_info->{interval_time} += $bug->{interval_time} if $interval_time;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
my $query_template_time = gettimeofday();
|
my $query_template_time = gettimeofday();
|
||||||
|
@ -806,15 +800,18 @@ if (@bugidlist)
|
||||||
}
|
}
|
||||||
|
|
||||||
# Compute percentage complete without rounding.
|
# Compute percentage complete without rounding.
|
||||||
my $sum = $time_info->{work_time} + $time_info->{remaining_time};
|
if (exists $total_info->{percentage_complete})
|
||||||
if ($sum > 0)
|
|
||||||
{
|
|
||||||
$time_info->{percentage_complete} = 100*$time_info->{work_time}/$sum;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
|
my $sum = $total_info->{work_time} + $total_info->{remaining_time};
|
||||||
|
if ($sum > 0)
|
||||||
|
{
|
||||||
|
$total_info->{percentage_complete} = 100*$total_info->{work_time}/$sum;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
# remaining_time <= 0
|
# remaining_time <= 0
|
||||||
$time_info->{percentage_complete} = 0
|
$total_info->{percentage_complete} = 0
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
|
@ -877,7 +874,7 @@ $vars->{order_columns} = $orderstrings;
|
||||||
$vars->{order_dir} = [ map { s/ DESC$// ? 1 : 0 } @{$vars->{order_columns}} ];
|
$vars->{order_dir} = [ map { s/ DESC$// ? 1 : 0 } @{$vars->{order_columns}} ];
|
||||||
|
|
||||||
$vars->{caneditbugs} = 1;
|
$vars->{caneditbugs} = 1;
|
||||||
$vars->{time_info} = $time_info;
|
$vars->{total_info} = $total_info;
|
||||||
|
|
||||||
$vars->{query_params} = { %$params }; # now used only in superworktime
|
$vars->{query_params} = { %$params }; # now used only in superworktime
|
||||||
$vars->{query_params}->{chfieldfrom} = $search->{interval_from};
|
$vars->{query_params}->{chfieldfrom} = $search->{interval_from};
|
||||||
|
|
|
@ -78,7 +78,8 @@ td.bz_total {
|
||||||
.bz_buglist .bz_estimated_time_column,
|
.bz_buglist .bz_estimated_time_column,
|
||||||
.bz_buglist .bz_remaining_time_column,
|
.bz_buglist .bz_remaining_time_column,
|
||||||
.bz_buglist .bz_work_time_column,
|
.bz_buglist .bz_work_time_column,
|
||||||
.bz_buglist .bz_percentage_complete_column { text-align: right; }
|
.bz_buglist .bz_percentage_complete_column,
|
||||||
|
.bz_buglist .bz_f30 { text-align: right; }
|
||||||
|
|
||||||
.bz_buglist .bz_short_desc_column,
|
.bz_buglist .bz_short_desc_column,
|
||||||
.bz_buglist .bz_short_short_desc_column,
|
.bz_buglist .bz_short_short_desc_column,
|
||||||
|
|
|
@ -282,7 +282,7 @@
|
||||||
|
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
[% IF loop.last() && time_info.time_present == 1 %]
|
[% IF loop.last() && total_info %]
|
||||||
[% PROCESS time_summary_line %]
|
[% PROCESS time_summary_line %]
|
||||||
[% END %]
|
[% END %]
|
||||||
|
|
||||||
|
@ -324,22 +324,18 @@
|
||||||
[% columns_to_span = columns_to_span + 1 %]
|
[% columns_to_span = columns_to_span + 1 %]
|
||||||
[% END %]
|
[% END %]
|
||||||
[% FOREACH column = displaycolumns %]
|
[% FOREACH column = displaycolumns %]
|
||||||
[% IF column == 'work_time' ||
|
[% IF total_info.defined(column) %]
|
||||||
column == 'remaining_time' ||
|
|
||||||
column == 'estimated_time' ||
|
|
||||||
column == 'percentage_complete' ||
|
|
||||||
column == 'interval_time' %]
|
|
||||||
[% IF columns_to_span > 0 %]
|
[% IF columns_to_span > 0 %]
|
||||||
<td class="bz_total bz_total_label" colspan="
|
<td class="bz_total bz_total_label" colspan="
|
||||||
[%- columns_to_span FILTER html %]"><b>Totals</b></td>
|
[%- columns_to_span FILTER html %]"><b>Totals</b></td>
|
||||||
[% columns_to_span = 0 %]
|
[% columns_to_span = 0 %]
|
||||||
[% END %]
|
[% END %]
|
||||||
[% IF column == 'percentage_complete' %]
|
[% IF column == 'percentage_complete' %]
|
||||||
<td class="bz_total">[% time_info.percentage_complete
|
<td class="bz_total">[% total_info.percentage_complete
|
||||||
FILTER format(abbrev.$column.format_value) FILTER html %]</td>
|
FILTER format(abbrev.$column.format_value) FILTER html %]</td>
|
||||||
[% ELSE %]
|
[% ELSE %]
|
||||||
<td class="bz_total">
|
<td class="bz_total">
|
||||||
[%- PROCESS formattimeunit time_unit=time_info.$column %]</td>
|
[%- PROCESS formattimeunit time_unit=total_info.$column %]</td>
|
||||||
[% END %]
|
[% END %]
|
||||||
[% ELSIF columns_to_span == 0 %] [%# A column following the first total %]
|
[% ELSIF columns_to_span == 0 %] [%# A column following the first total %]
|
||||||
<td class="bz_total"> </td>
|
<td class="bz_total"> </td>
|
||||||
|
|
Loading…
Reference in New Issue