Project

General

Profile

Feature #21450 » Add Total Estimated Time on Group Options.patch

Valdir Stiebe Junior, 2017-06-08 22:32

View differences:

issue_query.rb (working copy)
QueryColumn.new(:total_estimated_hours,
:sortable => "COALESCE((SELECT SUM(estimated_hours) FROM #{Issue.table_name} subtasks" +
" 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'),
:default_order => 'desc', :totalable => true),
QueryColumn.new(:done_ratio, :sortable => "#{Issue.table_name}.done_ratio", :groupable => true),
QueryColumn.new(:created_on, :sortable => "#{Issue.table_name}.created_on", :default_order => 'desc'),
QueryColumn.new(:closed_on, :sortable => "#{Issue.table_name}.closed_on", :default_order => 'desc'),
......
map_total(scope.sum(:estimated_hours)) {|t| t.to_f.round(2)}
end
# Returns sum of all the issue's total estimated_hours
def total_for_total_estimated_hours(scope)
total = scope.sum("COALESCE((SELECT SUM(estimated_hours) FROM #{Issue.table_name} subtasks" +
" WHERE subtasks.root_id = #{Issue.table_name}.root_id AND subtasks.lft >= #{Issue.table_name}.lft AND subtasks.rgt <= #{Issue.table_name}.rgt), 0)")
map_total(total) {|t| t.to_f.round(2)}
end
# Returns sum of all the issue's time entries hours
def total_for_spent_hours(scope)
total = if group_by_column.try(:name) == :project
(1-1/2)