Project

General

Profile

Actions

Patch #4776

closed

Totals for Estimated Time

Added by Ewan Makepeace almost 15 years ago. Updated almost 9 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
Issues
Target version:
-
Start date:
2010-02-09
Due date:
% Done:

50%

Estimated time:

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

total.jpg (23.4 KB) total.jpg Ewan Makepeace, 2010-02-09 08:25
grouptotal.jpg (26.9 KB) grouptotal.jpg Ewan Makepeace, 2010-02-09 08:25
TotalEstimatedTime.patch (7.33 KB) TotalEstimatedTime.patch Ewan Makepeace, 2010-02-09 08:25
sumEstimatedTimeByGroup.patch (2.8 KB) sumEstimatedTimeByGroup.patch Ewan Makepeace, 2010-02-09 08:25
subtotal-decimal.png (684 Bytes) subtotal-decimal.png subtotal rounding bug Victor Sergienko, 2010-11-22 15:24
sumEstimatedTimeByGroup.patch (2.79 KB) sumEstimatedTimeByGroup.patch Ewan Makepeace, 2010-11-23 05:08
totalTime.patch (1.01 KB) totalTime.patch Ewan Makepeace, 2010-11-23 05:08
estimated_hour_exclude_parent.diff (3.37 KB) estimated_hour_exclude_parent.diff RedminePro Yang, 2011-04-19 14:40
estimatedTime.diff (3.41 KB) estimatedTime.diff Diff file for Redmine 2.3.3 Olivier Houdas, 2013-10-17 13:20
estimatedTime-v2.dif (3.54 KB) estimatedTime-v2.dif Olivier Houdas, 2014-01-16 09:42
Redmine.org-4776-Estimated time patch for RM 3.0.3.patch (8.78 KB) Redmine.org-4776-Estimated time patch for RM 3.0.3.patch Olivier Houdas, 2015-06-24 19:33
RM3.0.3-Estimated-and-spent-times.png (57.5 KB) RM3.0.3-Estimated-and-spent-times.png Olivier Houdas, 2015-06-25 11:19
Redmine.org-4776-Estimated-time-patch_v1.1-for-RM-3.1.0.patch (9.71 KB) Redmine.org-4776-Estimated-time-patch_v1.1-for-RM-3.1.0.patch Olivier Houdas, 2015-08-14 16:14

Related issues

Related to Redmine - Feature #1561: Totals for estimated/spent time and numeric custom fields on the issue listClosedJean-Philippe Lang2008-07-02

Actions
Related to Redmine - Feature #6571: Totalise numeric columnsClosed2010-10-05

Actions
Related to Redmine - Feature #8559: Sum columns in reportsClosed2011-06-07

Actions
Follows Redmine - Patch #2268: Patch to show Total Estimated Time at the bottom of each list of issues.Closed2008-12-03

Actions
Actions #1

Updated by Victor Sergienko about 14 years ago

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 :)

Actions #2

Updated by Ewan Makepeace about 14 years ago

I believe this is our latest version, running on 1.0.2.
Let me know if it still gives errors.

Actions #3

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.

Actions #4

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.

Actions #5

Updated by RedminePro Yang over 13 years ago

With the attached patch, the parent task is excluded when sum the estimated hours for both current page and all pages.

Actions #6

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.

Actions #7

Updated by David Marín Carreño over 13 years ago

+1
Please, get this functionality into the main trunk.

Actions #8

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

Actions #9

Updated by pasquale [:dedalus] over 13 years ago

+1

Actions #10

Updated by Terence Mill over 13 years ago

+1

Please include this!

Totals for all number type fields on group header/footer is fundamental requirement here.

Actions #11

Updated by Jérôme BATAILLE over 13 years ago

+1

Actions #12

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

Actions #13

Updated by Matej Kenda about 13 years ago

I vote for inclusion of this patch into the release 1.2.2.

Actions #14

Updated by Giovani Spagnolo about 13 years ago

+1

Actions #15

Updated by Terence Mill about 13 years ago

+1

Actions #16

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.

Actions #17

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
Actions #18

Updated by strexy strexy over 12 years ago

Hello everybody,
is this useful patch compatible with Redmine 0.9.3 stable ?

Thanks in advance.

Actions #19

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

Actions #20

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.

Actions #21

Updated by Bill Wang over 12 years ago

the error msg?

Actions #22

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 %>

Actions #23

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.

Actions #24

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.

Actions #25

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

Actions #26

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

Actions #27

Updated by Olivier Houdas about 11 years ago

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.

Actions #28

Updated by nicola mondinelli about 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, '')

Actions #29

Updated by Olivier Houdas almost 11 years ago

True, Nicola. I fixed it in this patch: estimatedTime-v2.dif

Actions #30

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!

Actions #31

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!

Actions #32

Updated by Oscar Corsvall over 10 years ago

Does this patch work with redmine 2.5.0?

Actions #33

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!

Actions #34

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.

Actions #35

Updated by Artem Karamov over 9 years ago

Can anybody confirm if this nice patch work with redmine 3.0.3?

Actions #36

Updated by Olivier Houdas over 9 years ago

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!

Actions #37

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.

Actions #38

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.

Actions #39

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

Actions #40

Updated by Olivier Houdas over 9 years ago

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.

Actions #41

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?

Actions #42

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.

Actions

Also available in: Atom PDF