From f6ea714f52ae94d798ae1f4d47605942e00f790b Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sun, 5 Jul 2015 12:16:56 +0000 Subject: Adds "Total spent hours" column available on the issue list (#11253). git-svn-id: http://svn.redmine.org/redmine/trunk@14406 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/models/issue_query.rb | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'app/models') diff --git a/app/models/issue_query.rb b/app/models/issue_query.rb index 20ea59630..edc1290fe 100644 --- a/app/models/issue_query.rb +++ b/app/models/issue_query.rb @@ -267,6 +267,12 @@ class IssueQuery < Query :default_order => 'desc', :caption => :label_spent_time ) + @available_columns.insert index+1, QueryColumn.new(:total_spent_hours, + :sortable => "COALESCE((SELECT SUM(hours) FROM #{TimeEntry.table_name} JOIN #{Issue.table_name} subtasks ON subtasks.id = #{TimeEntry.table_name}.issue_id" + + " WHERE subtasks.root_id = #{Issue.table_name}.root_id AND subtasks.lft >= #{Issue.table_name}.lft AND subtasks.rgt <= #{Issue.table_name}.rgt), 0)", + :default_order => 'desc', + :caption => :label_total_spent_time + ) end if User.current.allowed_to?(:set_issues_private, nil, :global => true) || -- cgit v1.2.3