]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 316425: Summarize time estimates on buglist page - Patch by Aaron Larson <aaron...
authorlpsolit%gmail.com <>
Sun, 4 Jan 2009 17:44:35 +0000 (17:44 +0000)
committerlpsolit%gmail.com <>
Sun, 4 Jan 2009 17:44:35 +0000 (17:44 +0000)
buglist.cgi
skins/standard/buglist.css
template/en/default/list/table.html.tmpl

index 037edae708f5de1cac7abacde80f0e974162830f..32fb1b3f0a2dcd896f83b174e7b0051868a08a17 100755 (executable)
@@ -1065,6 +1065,22 @@ $buglist_sth->execute();
 # 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.
+my $percentage_complete = lsearch(\@displaycolumns, 'percentage_complete') >= 0;
+my $estimated_time      = lsearch(\@displaycolumns, 'estimated_time') >= 0;
+my $remaining_time    = ((lsearch(\@displaycolumns, 'remaining_time') >= 0)
+                         || $percentage_complete);
+my $actual_time       = ((lsearch(\@displaycolumns, 'actual_time') >= 0)
+                         || $percentage_complete);
+
+my $time_info = { 'estimated_time' => 0,
+                  'remaining_time' => 0,
+                  'actual_time' => 0,
+                  'percentage_complete' => 0,
+                  'time_present' => ($estimated_time || $remaining_time ||
+                                     $actual_time || $percentage_complete),
+                };
+    
 my $bugowners = {};
 my $bugproducts = {};
 my $bugstatuses = {};
@@ -1108,6 +1124,11 @@ while (my @row = $buglist_sth->fetchrow_array()) {
 
     # Add id to list for checking for bug privacy later
     push(@bugidlist, $bug->{'bug_id'});
+
+    # Compute time tracking info.
+    $time_info->{'estimated_time'} += $bug->{'estimated_time'} if ($estimated_time);
+    $time_info->{'remaining_time'} += $bug->{'remaining_time'} if ($remaining_time);
+    $time_info->{'actual_time'}    += $bug->{'actual_time'}    if ($actual_time);
 }
 
 # Check for bug privacy and set $bug->{'secure_mode'} to 'implied' or 'manual'
@@ -1140,6 +1161,15 @@ if (@bugidlist) {
     }
 }
 
+# Compute percentage complete without rounding.
+my $sum = $time_info->{'actual_time'}+$time_info->{'remaining_time'};
+if ($sum > 0) {
+    $time_info->{'percentage_complete'} = 100*$time_info->{'actual_time'}/$sum;
+}
+else { # remaining_time <= 0 
+    $time_info->{'percentage_complete'} = 0
+}                             
+
 ################################################################################
 # Template Variable Definition
 ################################################################################
@@ -1165,6 +1195,7 @@ $vars->{'urlquerypart'} = $params->canonicalise_query('order',
                                                       'query_based_on');
 $vars->{'order'} = $order;
 $vars->{'caneditbugs'} = 1;
+$vars->{'time_info'} = $time_info;
 
 if (!Bugzilla->user->in_group('editbugs')) {
     foreach my $product (keys %$bugproducts) {
index fa50bcb2d18e04d24bb615a6f23df983c089c012..fb4801d794a212ed3d16547cd1ceeeb319769b07 100644 (file)
@@ -71,6 +71,23 @@ tr.bz_secure_mode_implied td.first-child {
 tr.bz_secure_mode_manual td.first-child {
 }
 
+td.bz_estimated_time_column,
+td.bz_remaining_time_column,
+td.bz_actual_time_column,
+td.bz_percentage_complete_column {
+    text-align: right;
+}
+
+tr.bz_time_summary_line {
+    background: black;
+    color: white;
+}
+
+td.bz_total_label {
+    font-weight: bold;
+    text-align: right;
+}
+
 #commit, #action {
   margin-top: .25em;
 }
index 667d077f8ba81dd3f3ab706b1f23bb5e24e8eeaa..9b27b0094482422b8842b4fcb371256714629330 100644 (file)
     # end the current table. 
     #%]
   [% IF loop.last() || loop.count() % 100 == 0 %]
+    [% IF loop.last() && time_info.time_present == 1 %]
+      [% PROCESS time_summary_line %]
+    [% END %]
     </table>
   [% END %]
 
 [% END %]
+
+
+[% BLOCK time_summary_line %]
+  <tr class="bz_time_summary_line">
+    [% columns_to_span = 1 %]  [%# bugID %]
+    [% IF dotweak %]
+      [% columns_to_span = columns_to_span + 1 %]
+    [% END %]
+    [% FOREACH column = displaycolumns %]
+      [% IF column == 'actual_time' ||
+            column == 'remaining_time' ||
+            column == 'estimated_time' ||
+            column == 'percentage_complete' %]
+        [% IF columns_to_span > 0 %]
+          <td class="bz_total_label" colspan="[% columns_to_span FILTER html %]"><b>Totals</b></td>
+          [% columns_to_span = 0 %]
+        [% END %]
+        [% IF column == 'percentage_complete' %]
+          <td>[% time_info.percentage_complete FILTER format(abbrev.$column.format_value) FILTER html -%]</td>
+        [% ELSE %]
+          <td>[% PROCESS formattimeunit time_unit=time_info.$column %]</td>
+        [% END %]
+      [% ELSIF columns_to_span == 0 %] [%# A column following the first total %]
+        <td>&nbsp;</td>
+      [% ELSE %] [%# We haven't gotten to a time column yet, keep computing span %]
+        [% columns_to_span = columns_to_span + 1 %]
+      [% END %]
+    [% END %]
+  </tr>
+[% END %]