@@ -206,6 +206,7 class Issue < ActiveRecord::Base | |||
|
206 | 206 | @assignable_versions = nil |
|
207 | 207 | @relations = nil |
|
208 | 208 | @spent_hours = nil |
|
209 | @total_spent_hours = nil | |
|
209 | 210 | @total_estimated_hours = nil |
|
210 | 211 | base_reload(*args) |
|
211 | 212 | end |
@@ -916,15 +917,13 class Issue < ActiveRecord::Base | |||
|
916 | 917 | end |
|
917 | 918 | |
|
918 | 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 | 920 | def total_spent_hours |
|
924 | @total_spent_hours ||= | |
|
925 | self_and_descendants. | |
|
926 | joins("LEFT JOIN #{TimeEntry.table_name} ON #{TimeEntry.table_name}.issue_id = #{Issue.table_name}.id"). | |
|
927 | sum("#{TimeEntry.table_name}.hours").to_f || 0.0 | |
|
921 | if leaf? | |
|
922 | spent_hours | |
|
923 | else | |
|
924 | @total_spent_hours ||= | |
|
925 | self_and_descendants.joins(:time_entries).sum("#{TimeEntry.table_name}.hours").to_f || 0.0 | |
|
926 | end | |
|
928 | 927 | end |
|
929 | 928 | |
|
930 | 929 | def total_estimated_hours |
General Comments 0
You need to be logged in to leave comments.
Login now