Patch #4776
Totals for Estimated Time
| Status: | New | Start date: | 2010-02-09 | ||
|---|---|---|---|---|---|
| Priority: | Normal | Due date: | |||
| Assignee: | - | % Done: | 50% | ||
| Category: | Issues | ||||
| Target version: | - |
Description
We use the estimated time field extensively to both manage our work and reward our developers. We have developed two patches for Redmine that I find indispensible. One was previously posted and I thought had been accepted into the trunk, but does not seem to be there in 0.9. The other we have created to improve the (fantastic) new 'Group By' functionality.
The older patch gives Total Estimated Time for all issues on the page, and all issues across all pages, at the bottom of all issue lists:

The second provides a total of the estimated times of issues in a sub group:

We are not a Ruby shop - the code can probably be improved. If so please post back here!
PS: I tried to post a patch here once before and it was an embarrassing failure. Apologies in advance if this does not work out again!
Related issues
History
#1 Updated by Victor Sergienko over 2 years ago
- File subtotal-decimal.png added
Thank you a lot!
What version is the for? TotalEstimatedTime.patch didn't apply to my 1.0.3 (2010-10-31), though sumEstimatedTimeByGroup.patch did.
I also got a rounding bug from somewhere, see subtotal-decimal.png attachment. I don't have such a fractional estimations :)
#2 Updated by Ewan Makepeace over 2 years ago
- File sumEstimatedTimeByGroup.patch
added - File totalTime.patch
added
I believe this is our latest version, running on 1.0.2.
Let me know if it still gives errors.
#3 Updated by Victor Sergienko over 2 years ago
May I ask you one more thing? On Redmine 1.1, with subtasks, it counts subtasks' hours alongside with parent's, so a subtask gets counted twice.
Can you please exclude issues with nonempty children?
Thanks.
#4 Updated by Ewan Makepeace about 2 years ago
I know - it is a real pain. We are looking to update as you suggest. Will advise here.
#5 Updated by RedminePro Yang about 2 years ago
- File estimated_hour_exclude_parent.diff
added - % Done changed from 0 to 50
With the attached patch, the parent task is excluded when sum the estimated hours for both current page and all pages.
#6 Updated by Ewan Makepeace about 2 years ago
+1
We are using this to exclude parents from totals on current page, all pages and group totals. Note however that it does not (I think) exclude parents from CSV listings ect.
#7 Updated by David Marín Carreño about 2 years ago
+1
Please, get this functionality into the main trunk.
#8 Updated by Terence Mill about 2 years ago
+1 FOR..
Calculated fields can be optionally switched on per poeject and tracker and field.
...calculation can be
- sum
- average
- max
- min
...Calculcated values can be shown for
- a task (included subtash ) in issue form, e.g at the bottom
- issue list as summary for filtered issues (mean same values on every page if search result is splitted on several result pages)
- on issue list group level a total for every group
We would need that for estimation and spent time and total numer of issues for a group
#9 Updated by pasquale [:dedalus] over 1 year ago
+1
#10 Updated by Terence Mill over 1 year ago
+1
Please include this!
Totals for all number type fields on group header/footer is fundamental requirement here.
#11 Updated by Jérôme BATAILLE over 1 year ago
+1
#12 Updated by Mischa The Evil over 1 year ago
As mentioned the first time by Tony Marschall in #8559 note-4, there exists a plugin which provides (parts of) this feature (along with some others): Redmine spent time column. It's written by Jan Schulz-Hofen of plan.io.
I've started working on some improvements to make it better suitable for this issue in my fork of it:
https://github.com/MischaTheEvil/redmine_spent_time_column
#13 Updated by Matej Kenda over 1 year ago
I vote for inclusion of this patch into the release 1.2.2.
#14 Updated by Giovani Spagnolo over 1 year ago
+1
#15 Updated by Terence Mill over 1 year ago
+1
#16 Updated by Matej Kenda over 1 year ago
Matej Kenda wrote:
I vote for inclusion of this patch into the release 1.2.2.
Or 1.2.3 since 1.2.2 was just released.
#17 Updated by Nicolas Ottavi about 1 year ago
Hi,
My two cents, I am not a redmine export nor a ruby developer at all, but I was wondering if adding function which return the total estimation time in the project Model would not be a good solution. This way we could use this value anywhere in redmine where projects are listed ?
def estimated_duration
issues.sum(:estimated_hours, :include => [:status,:project], :conditions => Issue.merge_conditions(nil, "#{Issue.table_name}.rgt - #{Issue.table_name}.lft = 1"))
rescue ::ActiveRecord::StatementInvalid => e
raise StatementInvalid.new(e.message)
end
#18 Updated by strexy strexy 10 months ago
Hello everybody,
is this useful patch compatible with Redmine 0.9.3 stable ?
Thanks in advance.
#19 Updated by Ewan Makepeace 10 months ago
We are currently running 1.3 and I could not use redmine without these group and running totals. However the first attached version of the patch was written for 0.9 so I think there is a good chance it would run with 0.9.3
#20 Updated by strexy strexy 10 months ago
Hi all,
on my 0.9.3 I've successfully installed the TotalEstimatedTime.patch but the very useful sumEstimatedTimeByGroup.patch generates an error as I try to group a tasks list.
It seems that this
<%= @issue_sum_by_group[group] %> (line 22 of views/issues/_list.rhtml)
is not compatible for whatever reason.
It's declared in models/query.rb
#Returns sum of the issue's estimated_hours by group or nil if query is not grouped
def issue_sum_by_group
r = nil
if grouped?
begin
r = Issue.sum(:estimated_hours, :group => group_by_statement, :include => [:status, :project], :conditions => statement)
rescue ActiveRecord::RecordNotFound
r= {r => issue_sum}
end
c = group_by_column
if c.is_a?(QueryCustomFieldColumn)
r = r.keys.inject({}) {|h, k| h[c.custom_field.cast_value(k)] = r[k]; h}
end
end
r
rescue ::ActiveRecord::StatementInvalid => e
raise StatementInvalid.new(e.message)
end
Maybe someone have already solved this issue.
I'm not a coder at all.
Thanks in advance.
#22 Updated by strexy strexy 9 months ago
ActionView::TemplateError (undefined method `[]' for nil:NilClass) on line #22 of app/views/issues/_list.rhtml:
19: <tr class="group open">
20: <td colspan="<%= query.columns.size + 2 >">
21: <span class="expander" onclick="toggleRowGroup(this); return false;"> </span>
22: <= group.blank? ? 'None' : column_content(@query.group_by_column, issue) > <span class="count">(<= @issue_sum_by_group[group] >)</span>
23: </td>
24: </tr>
25: < previous_group = group %>
#23 Updated by Bill Wang 9 months ago
hi strexy, it means @issue_sum_by_group is nil.
so, maybe:
1. check whether you missed something.
--- app/controllers/issues_controller.rb (revision 4884)
+++ app/controllers/issues_controller.rb (working copy)
@@ -85,7 +85,8 @@
:order => sort_clause,
:offset => @offset,
:limit => @limit)
- @issue_count_by_group = @query.issue_count_by_group
+ @issue_count_by_group = @query.issue_count_by_group
+ @issue_sum_by_group = @query.issue_sum_by_group
2.
+ # Returns sum of the issue's estimated_hours by group or nil if query is not grouped
+ def issue_sum_by_group
+ r = nil
+ if grouped?
+ begin
+ r = Issue.sum(:estimated_hours, :group => group_by_statement, :include => [:status, :project],
+ :conditions => Issue.merge_conditions(statement , "#{Issue.table_name}.rgt - #{Issue.table_name}.lft = 1"))
+ rescue ActiveRecord::RecordNotFound
+ r= {r => issue_sum}
+ end
+
+ c = group_by_column
+ if c.is_a?(QueryCustomFieldColumn)
+ r = r.keys.inject({}) {|h, k| h[c.custom_field.cast_value(k)] = r[k]; h}
+ end
+ end
+ r
+ rescue ::ActiveRecord::StatementInvalid => e
+ raise StatementInvalid.new(e.message)
+ end
+
maybe because of "nil if query is not grouped".
however, accodring to my testing in my redmine, it will not go that line code if not groupd.
<% if @query.grouped? && (group = @query.group_by_column.value(issue)) != previous_group %> <--it means has_groupd and this_groupd is not equal to previous_group.
so I guess you missed something.
#24 Updated by strexy strexy 9 months ago
Thanks Bill,
for sure I've missed something.
As you said, it didn't worked only when grouped.
I'll check it after my vacations.
I'll let you know.
Thanks.