From fd742d6fc8849328749866dbff2936d43abcc7d1 Mon Sep 17 00:00:00 2001 From: "bugreport%peshkin.net" <> Date: Sun, 13 Oct 2002 11:26:02 +0000 Subject: Bug 24789 [E|A|R] Add Estimated, Actual, Remaining Time Fields patch by jeff.hedlund@matrixsi.com 2xr=joel,justdave --- buglist.cgi | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) (limited to 'buglist.cgi') diff --git a/buglist.cgi b/buglist.cgi index 9f00e15ae..e71db0618 100755 --- a/buglist.cgi +++ b/buglist.cgi @@ -382,8 +382,10 @@ DefineColumn("os" , "bugs.op_sys" , "OS" DefineColumn("target_milestone" , "bugs.target_milestone" , "Target Milestone" ); DefineColumn("votes" , "bugs.votes" , "Votes" ); DefineColumn("keywords" , "bugs.keywords" , "Keywords" ); - - +DefineColumn("estimated_time" , "bugs.estimated_time" , "Estimated Hours" ); +DefineColumn("remaining_time" , "bugs.remaining_time" , "Remaining Hours" ); +DefineColumn("actual_time" , "(SUM(ldtime.work_time)*COUNT(DISTINCT ldtime.bug_when)/COUNT(bugs.bug_id)) AS actual_time", "Actual Hours"); +DefineColumn("percentage_complete","(100*((SUM(ldtime.work_time)*COUNT(DISTINCT ldtime.bug_when)/COUNT(bugs.bug_id))/((SUM(ldtime.work_time)*COUNT(DISTINCT ldtime.bug_when)/COUNT(bugs.bug_id))+bugs.remaining_time))) AS percentage_complete", "% Complete"); ################################################################################ # Display Column Determination ################################################################################ @@ -430,6 +432,14 @@ if (trim($::FORM{'votes'}) && !grep($_ eq 'votes', @displaycolumns)) { push(@displaycolumns, 'votes'); } +# Remove the timetracking columns if they are not a part of the group +# (happens if a user had access to time tracking and it was revoked/disabled) +if (!UserInGroup(Param("timetrackinggroup"))) { + @displaycolumns = grep($_ ne 'estimated_time', @displaycolumns); + @displaycolumns = grep($_ ne 'remaining_time', @displaycolumns); + @displaycolumns = grep($_ ne 'actual_time', @displaycolumns); + @displaycolumns = grep($_ ne 'percentage_complete', @displaycolumns); +} ################################################################################ # Select Column Determination @@ -440,6 +450,12 @@ if (trim($::FORM{'votes'}) && !grep($_ eq 'votes', @displaycolumns)) { # The bug ID is always selected because bug IDs are always displayed my @selectcolumns = ("id"); +# remaining and actual_time are required for precentage_complete calculation: +if (lsearch(\@displaycolumns, "percentage_complete")) { + push (@selectcolumns, "remaining_time"); + push (@selectcolumns, "actual_time"); +} + # Display columns are selected because otherwise we could not display them. push (@selectcolumns, @displaycolumns); @@ -459,6 +475,10 @@ if ($dotweak) { # Convert the list of columns being selected into a list of column names. my @selectnames = map($columns->{$_}->{'name'}, @selectcolumns); +# Remove columns with no names, such as percentage_complete +# (or a removed *_time column due to permissions) +@selectnames = grep($_ ne '', @selectnames); + # Generate the basic SQL query that will be used to generate the bug list. my $search = new Bugzilla::Search('fields' => \@selectnames, 'url' => $::buffer); @@ -538,6 +558,15 @@ if ($order) { # sort order was given $db_order =~ s/bugs.votes\s*(,|$)/bugs.votes desc$1/i; + # the 'actual_time' field is defined as an aggregate function, but + # for order we just need the column name 'actual_time' + my $aggregate_search = quotemeta($columns->{'actual_time'}->{'name'}); + $db_order =~ s/$aggregate_search/actual_time/g; + + # the 'percentage_complete' field is defined as an aggregate too + $aggregate_search = quotemeta($columns->{'percentage_complete'}->{'name'}); + $db_order =~ s/$aggregate_search/percentage_complete/g; + $query .= " ORDER BY $db_order "; } -- cgit v1.2.3-24-g4f1b