diff --git a/app/models/issue.rb b/app/models/issue.rb index 9b6be7db6..be69d929f 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -522,7 +522,8 @@ class Issue < ActiveRecord::Base # spent_hours => 0.0 # spent_hours => 50.2 def total_spent_hours - @total_spent_hours ||= self_and_descendants.sum("#{TimeEntry.table_name}.hours", :include => :time_entries).to_f || 0.0 + @total_spent_hours ||= self_and_descendants.sum("#{TimeEntry.table_name}.hours", + :joins => "LEFT JOIN #{TimeEntry.table_name} ON #{TimeEntry.table_name}.issue_id = #{Issue.table_name}.id").to_f || 0.0 end def relations