Patch #2268

Patch to show Total Estimated Time at the bottom of each list of issues.

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

Status:ClosedStart date:2008-12-03
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:Time tracking
Target version:-

Description

Provides a total of estimated time for all the issues in a list, like this:

Not totally certain this is the correct file format and naming - first try at uploading a patch.

total_estimated_hour.diff Magnifier (991 Bytes) Ewan Makepeace, 2008-12-03 04:55

times.jpg (66.5 KB) Ewan Makepeace, 2010-10-25 22:49

total_estimated_hour_2_6_4.sql (64 Bytes) Muhammad Azmi Farih, 2015-04-27 12:02

total_estimated_hour_2_6_4.diff Magnifier (37.2 KB) Muhammad Azmi Farih, 2015-04-27 12:02

total_estimated_hour_2_6_4_edited.diff Magnifier (12.7 KB) Muhammad Azmi Farih, 2015-05-04 09:58


Related issues

Related to Redmine - Feature #1561: Totals for estimated/spent time and numeric custom fields... Closed 2008-07-02
Related to Redmine - Feature #6571: Totalise numeric columns Closed 2010-10-05
Related to Redmine - Feature #8559: Sum columns in reports Closed 2011-06-07
Duplicated by Redmine - Feature #1374: Estimated hours sum in query listing Closed 2008-06-04
Precedes Redmine - Patch #4776: Totals for Estimated Time Closed 2010-02-09

History

#1 Updated by Eric Davis almost 9 years ago

The patch is a good start and is in the correct format. There are a couple of improvements:

  • Using send isn't necessary. issue.estimated_hours would work
  • Some unit tests would be helpful

Another improvement would be to replace the entire loop with:

@issues.collect(&:estimated_hours).reject {|hours| hours.nil?}.sum

#2 Updated by Jean-Philippe Lang almost 9 years ago

Or:

@issues.collect(&:estimated_hours).compact.sum

But the problem is that it calculates the total for the issues that are displayed only.
If the issue list has more than one page, this is a partial sum.

If we really want to add this feature, we'd better do a query to sum the estimated hours of all the filtered issues. IMHO, it makes more sense.

Adding something like this to the controller should almost work (not tested):

@estimated = Issue.sum :estimated_hours, 
                       :include => [ :status, :project ],
                       :conditions => @query.statement

#3 Updated by Eric Davis almost 9 years ago

Jean-Philippe Lang wrote:

But the problem is that it calculates the total for the issues that are displayed only.
If the issue list has more than one page, this is a partial sum.

Opps, I thought that was what the feature was for "xxx time in the list"

#4 Updated by Eric Davis almost 9 years ago

  • Status changed from New to 7
  • Assignee set to Eric Davis

I've got a working patch for this feature, I'll commit it soon.

#5 Updated by Ewan Makepeace almost 9 years ago

Adding up the total estimated time for all issues (visible or not) might be dangerous - what if we click "All Issues" on a big database with thousands of issues - will they all be loaded into memory in order to sum their estimated time (unsure whether Active Record does this in memory or is smart and just calls "Select sum(EstimatedTime) from ..." ect).

I use the original patch daily and am very happy with it - if it is to be improved I would rather see subtotals for each discrete value in the sorted column before grand totals for all records.

#6 Updated by Eric Davis almost 9 years ago

Ewan Makepeace: Good thinking. Active Record does it as a single SUM query so it should be fine.

SQL (0.000110) SELECT sum(`issues`.estimated_hours) AS sum_estimated_hours 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 ((issue_statuses.is_closed=0) AND ((projects.status=1 AND EXISTS (SELECT em.id FROM enabled_modules em WHERE em.name='issue_tracking' AND em.project_id=projects.id)) AND (1=0 OR projects.is_public = 1)))

#7 Updated by Jean-Philippe Lang almost 9 years ago

Ewan Makepeace wrote:

Adding up the total estimated time for all issues (visible or not) might be dangerous - what if we click "All Issues" on a big database with thousands of issues - will they all be loaded into memory in order to sum their estimated time (unsure whether Active Record does this in memory or is smart and just calls "Select sum(EstimatedTime) from ..." ect).

I wouldn't have submitted such code if I was unsure of what Issue.sum does.

#8 Updated by Eric Davis almost 7 years ago

  • Assignee deleted (Eric Davis)

#9 Updated by Ewan Makepeace almost 7 years ago

Eric, we are still using a version of this patch today (some changes since the first version I think). It gives us issue count and total estimated time per group plus page and query totals of estimated time:

Let me know if any interest in our current patch.

#10 Updated by Victor Sergienko almost 7 years ago

Hi Evan,
Can you please share your patch in some way? I'd like to have it very much.
Thanks!

#11 Updated by Etienne Massip over 6 years ago

  • Category changed from Issues to Time tracking

#12 Updated by Ewan Makepeace over 6 years ago

Victor See here: #4776

#13 Updated by Mischa The Evil almost 6 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

#14 Updated by Jean-Philippe Lang almost 5 years ago

  • Status changed from 7 to New

Assigned issue with no assignee back to New status.

#15 Updated by Sergey W about 3 years ago

are there sulutions for redmine 2.5 ?

#16 Updated by Henry Auffahrt over 2 years ago

@Mischa The Evil,
as i see i can not install your fork of the plugin, maybe because we use redmine 2.6.1???

@all
This would be an awesome feature for us! We want to use our redmine system for our capacity planning. This would improve our work enormously :)

#17 Updated by Muhammad Azmi Farih over 2 years ago

Hi All,

This patch is work on redmine 2.6.4.

Regards

#18 Updated by Ewan Makepeace over 2 years ago

To clarify - the previous post by Muhammad Azmi contains the current version of our patches to show estimated time totals on groups and at the foot of pages as originally described.

#19 Updated by Muhammad Azmi Farih over 2 years ago

Please use this patch rather than previous, I have cleaned up the patch more correctly.

#20 Updated by Toshi MARUYAMA almost 2 years ago

  • Status changed from New to Closed

Fixed by #1561.

Also available in: Atom PDF