diff --git a/lib/redmine/helpers/time_report.rb b/lib/redmine/helpers/time_report.rb index 2c71f098b..14a09694e 100644 --- a/lib/redmine/helpers/time_report.rb +++ b/lib/redmine/helpers/time_report.rb @@ -45,10 +45,10 @@ module Redmine unless @criteria.empty? time_columns = %w(tyear tmonth tweek spent_on) @hours = [] - @scope.sum(:hours, - :include => [:issue, :activity], - :group => @criteria.collect{|criteria| @available_criteria[criteria][:sql]} + time_columns, - :joins => @criteria.collect{|criteria| @available_criteria[criteria][:joins]}.compact).each do |hash, hours| + @scope.includes(:issue, :activity). + group(@criteria.collect{|criteria| @available_criteria[criteria][:sql]} + time_columns). + joins(@criteria.collect{|criteria| @available_criteria[criteria][:joins]}.compact). + sum(:hours).each do |hash, hours| h = {'hours' => hours} (@criteria + time_columns).each_with_index do |name, i| h[name] = hash[i]