##// END OF EJS Templates
Rails4: replace deprecated Relation#sum with finder options at Issue#total_spent_hours...
Toshi MARUYAMA -
r12313:56a3c1ad40e7
parent child
Show More
@@ -839,8 +839,10 class Issue < ActiveRecord::Base
839 # spent_hours => 0.0
839 # spent_hours => 0.0
840 # spent_hours => 50.2
840 # spent_hours => 50.2
841 def total_spent_hours
841 def total_spent_hours
842 @total_spent_hours ||= self_and_descendants.sum("#{TimeEntry.table_name}.hours",
842 @total_spent_hours ||=
843 :joins => "LEFT JOIN #{TimeEntry.table_name} ON #{TimeEntry.table_name}.issue_id = #{Issue.table_name}.id").to_f || 0.0
843 self_and_descendants.
844 joins("LEFT JOIN #{TimeEntry.table_name} ON #{TimeEntry.table_name}.issue_id = #{Issue.table_name}.id").
845 sum("#{TimeEntry.table_name}.hours").to_f || 0.0
844 end
846 end
845
847
846 def relations
848 def relations
General Comments 0
You need to be logged in to leave comments. Login now