##// END OF EJS Templates
Code cleanup....
Jean-Philippe Lang -
r13892:5e28f0b1b6aa
parent child
Show More
@@ -206,6 +206,7 class Issue < ActiveRecord::Base
206 @assignable_versions = nil
206 @assignable_versions = nil
207 @relations = nil
207 @relations = nil
208 @spent_hours = nil
208 @spent_hours = nil
209 @total_spent_hours = nil
209 @total_estimated_hours = nil
210 @total_estimated_hours = nil
210 base_reload(*args)
211 base_reload(*args)
211 end
212 end
@@ -916,15 +917,13 class Issue < ActiveRecord::Base
916 end
917 end
917
918
918 # Returns the total number of hours spent on this issue and its descendants
919 # Returns the total number of hours spent on this issue and its descendants
919 #
920 # Example:
921 # spent_hours => 0.0
922 # spent_hours => 50.2
923 def total_spent_hours
920 def total_spent_hours
924 @total_spent_hours ||=
921 if leaf?
925 self_and_descendants.
922 spent_hours
926 joins("LEFT JOIN #{TimeEntry.table_name} ON #{TimeEntry.table_name}.issue_id = #{Issue.table_name}.id").
923 else
927 sum("#{TimeEntry.table_name}.hours").to_f || 0.0
924 @total_spent_hours ||=
925 self_and_descendants.joins(:time_entries).sum("#{TimeEntry.table_name}.hours").to_f || 0.0
926 end
928 end
927 end
929
928
930 def total_estimated_hours
929 def total_estimated_hours
General Comments 0
You need to be logged in to leave comments. Login now