Patch #4776
closedTotals for Estimated Time
50%
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!
Files
Related issues
Updated by Victor Sergienko almost 14 years ago
- File subtotal-decimal.png 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 :)
Updated by Ewan Makepeace almost 14 years ago
- File sumEstimatedTimeByGroup.patch sumEstimatedTimeByGroup.patch added
- File totalTime.patch totalTime.patch added
I believe this is our latest version, running on 1.0.2.
Let me know if it still gives errors.
Updated by Victor Sergienko almost 14 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.
Updated by Ewan Makepeace almost 14 years ago
I know - it is a real pain. We are looking to update as you suggest. Will advise here.
Updated by RedminePro Yang over 13 years ago
- File estimated_hour_exclude_parent.diff 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.
Updated by Ewan Makepeace over 13 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.
Updated by David Marín Carreño over 13 years ago
+1
Please, get this functionality into the main trunk.
Updated by Terence Mill over 13 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
Updated by Terence Mill about 13 years ago
+1
Please include this!
Totals for all number type fields on group header/footer is fundamental requirement here.
Updated by Mischa The Evil about 13 years 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
Updated by Matej Kenda about 13 years ago
I vote for inclusion of this patch into the release 1.2.2.
Updated by Matej Kenda about 13 years 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.
Updated by Nicolas Ottavi over 12 years 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
Updated by strexy strexy over 12 years ago
Hello everybody,
is this useful patch compatible with Redmine 0.9.3 stable ?
Thanks in advance.
Updated by Ewan Makepeace over 12 years 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
Updated by strexy strexy over 12 years 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.
Updated by strexy strexy over 12 years 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 %>
Updated by Bill Wang over 12 years 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.
Updated by strexy strexy over 12 years 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.
Updated by michel p over 11 years ago
Hi,
I try to use the patch... without even know how to code "hello world" with ruby :)
Can someone is able to convert the ":conditions => Issue.merge_conditions(statement..." with scope ?
I use version 2.3.1 and merge_condition seems an deprecated way to do the stuff
thx
Updated by michel p over 11 years ago
UPDATE:
it seems that works with this patch:
-:conditions => Issue.merge_conditions(statement , "#{Issue.table_name}.rgt - #{Issue.table_name}.lft = 1"))
+:conditions => [(statement), ("#{Issue.table_name}.rgt - #{Issue.table_name}.lft = 1")])
there is 2 lines like this in the patch
I'm not sure that this kind of code is correct so if a ruby coder can produce a valid patch for rails 3 it would be better
Hope that can help
Updated by Olivier Houdas about 11 years ago
- File estimatedTime.diff estimatedTime.diff added
It almost did it, but actually created an issue for filters which use the Contains operator.
Indeed, that filtering operator results in conditions like "WHERE LOWER LIKE '%test%'", which raised the error : "ActionView::Template::Error (invalid format character - %):" when using the array.
I have changed it to
-:conditions => Issue.merge_conditions(statement , "#{Issue.table_name}.rgt - #{Issue.table_name}.lft = 1"))
+:conditions => statement << "AND #{Issue.table_name}.rgt - #{Issue.table_name}.lft = 1")
which seems to work.
I'm attaching the .diff file for Redmine 2.3.3 to help even more.
Note that in addition to that change, I slightly modified the text displayed in this version, so that it indicates "estimated time : xx hours" instead of just a number.
The patch contains a hardcoded string for the end of page summary ("current page"), I did not change that.
Updated by nicola mondinelli almost 11 years ago
Olivier Houdas wrote:
I'm attaching the .diff file for Redmine 2.3.3 to help even more.
Note that in addition to that change, I slightly modified the text displayed in this version, so that it indicates "estimated time : xx hours" instead of just a number.The patch contains a hardcoded string for the end of page summary ("current page"), I did not change that.
Oliver, i spotted a issue in the patch: on grouping on custom field i've got a 500 error:
Query::StatementInvalid: Mysql2::Error: Unknown column 'cf_5.value' in 'field list': SELECT SUM(`issues`.`estimated_hours`) AS sum_estimated_hours, COALESCE(cf_5.value, '') AS coalesce_cf_5_value FROM `issues` LEFT OUTER JOIN `issue_statuses` ON `issue_statuses`.`id` = `issues`.`status_id` LEFT OUTER JOIN `projects` ON `projects`.`id` = `issues`.`project_id` WHERE ((issues.status_id IN (SELECT id FROM issue_statuses WHERE is_closed=0)) AND projects.id = 15 AND issues.rgt - issues.lft = 1) GROUP BY COALESCE(cf_5.value, '')
Updated by Olivier Houdas almost 11 years ago
- File estimatedTime-v2.dif estimatedTime-v2.dif added
True, Nicola. I fixed it in this patch: estimatedTime-v2.dif
Updated by Jessica Berriman almost 11 years ago
I'm trying to install this plugin/patch to our Redmine configuration (4.2 on Windows), but I'm admittedly new to Redmine and am not sure how to get this functionality installed.
Could anyone provide guidance for this?
Much appreciated in advance!
Updated by Jan from Planio www.plan.io almost 11 years ago
This tracker is for Redmine bugs/features/patches only. To request guidance, please ask in the forums. Thanks!
Updated by Oscar Corsvall over 10 years ago
Does this patch work with redmine 2.5.0?
Updated by Ewan Makepeace over 10 years ago
We are still on Redmine 2.0.3.devel.10073 - I am surprised we have got so far behind, I need to check what is new in Redmine!
Updated by Olivier Houdas over 10 years ago
I did upgrade sucessfully with this code (estimatedTime-v2.dif ) to 2.4.3. I haven't upgraded to 2.5.1 yet.
Updated by Artem Karamov over 9 years ago
Can anybody confirm if this nice patch work with redmine 3.0.3?
Updated by Olivier Houdas over 9 years ago
- File Redmine.org-4776-Estimated time patch for RM 3.0.3.patch Redmine.org-4776-Estimated time patch for RM 3.0.3.patch added
It does not: some code was moved to a helper file between 2.6 and 3.0.
You will find attached the patch of our changes on 3.0.3.
It also includes displaying spent time subtotals for grouped queries.
Note that when parents tasks are shown with their children in the same group, the spent time is counted twice. I haven't found out how to fix that issue so far.
I also haven't found how to manage to get spent time when the issues are grouped by project.
I don't guarantee the quality of the code, as I'm pretty new to Ruby... remarks / improvements are welcome!
Updated by Olivier Houdas over 9 years ago
For those interested, here is a screenshot of how we use the patch.
We manage our Agile sprints on Redmine, and this query filters on one sprint, grouping test tasks per product.
We group by tester to ensure the load is evenly spread, and by product to inform product owners about the planned test efforts.
Updated by Ewan Makepeace over 9 years ago
It seems we have a couple of issues covering the same issue. We recently posted our current patch version on this issue #2268 but not here.
No change in functionality - just tracking redmine changes, I am completely unsure how that code and the code describes here differs.
Updated by Artem Karamov over 9 years ago
Thank you very much, Olivier! Installed it on 3.0.3
Very useful patch for planning and review of previous sprints/versions
Updated by Olivier Houdas over 9 years ago
- File Redmine.org-4776-Estimated-time-patch_v1.1-for-RM-3.1.0.patch Redmine.org-4776-Estimated-time-patch_v1.1-for-RM-3.1.0.patch added
I fixed a case of Error 500 on the previous patch, which happens when sorting on a column selected for grouping.
Attached is the full patch with the fix, produced on Redmine 3.1.0.
Updated by Jonathan Vargas about 9 years ago
This worked fine for us. I just removed the unpaired parentheses at the footer of the query results. Thanks, I'm not Ruby developer, but could this patch be a plugin instead?
Updated by Toshi MARUYAMA almost 9 years ago
- Status changed from New to Closed
I think this issue is fixed by #1561.
If you have more request, please create new issue.