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]