Index: issue_query.rb =================================================================== --- issue_query.rb (revision 50) +++ issue_query.rb (working copy) @@ -38,7 +38,7 @@ 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'), @@ -322,6 +322,15 @@ 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