Project

General

Profile

Feature #11253 » spent_time_on_parents_hack.patch

#11253_vs_redmine230 - Henrik Leon, 2013-04-27 19:32

View differences:

app/models/issue_query.rb
196 196
      index = nil
197 197
      @available_columns.each_with_index {|column, i| index = i if column.name == :estimated_hours}
198 198
      index = (index ? index + 1 : -1)
199
      # insert the column after estimated_hours or at the end
200
      @available_columns.insert index, QueryColumn.new(:spent_hours,
201
        :sortable => "COALESCE((SELECT SUM(hours) FROM #{TimeEntry.table_name} WHERE #{TimeEntry.table_name}.issue_id = #{Issue.table_name}.id), 0)",
199
      @available_columns.insert index, QueryColumn.new(:total_spent_hours,
200
        :sortable => "COALESCE((SELECT SUM(hours) FROM #{TimeEntry.table_name} time_entry LEFT JOIN #{Issue.table_name} child_issue ON time_entry.issue_id = child_issue.id WHERE #{TimeEntry.table_name}.issue_id = #{Issue.table_name}.id OR child_issue.parent_id IS NOT NULL), 0)",
202 201
        :default_order => 'desc',
203 202
        :caption => :label_spent_time
204 203
      )
(4-4/9)