1
0
mirror of https://github.com/meineerde/redmine.git synced 2025-10-17 17:01:01 +00:00

Code cleanup.

git-svn-id: http://svn.redmine.org/redmine/trunk@14274 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2015-05-25 12:09:01 +00:00
parent 31bffaa053
commit 5e28f0b1b6

View File

@ -206,6 +206,7 @@ class Issue < ActiveRecord::Base
@assignable_versions = nil
@relations = nil
@spent_hours = nil
@total_spent_hours = nil
@total_estimated_hours = nil
base_reload(*args)
end
@ -916,15 +917,13 @@ class Issue < ActiveRecord::Base
end
# Returns the total number of hours spent on this issue and its descendants
#
# Example:
# spent_hours => 0.0
# spent_hours => 50.2
def total_spent_hours
@total_spent_hours ||=
self_and_descendants.
joins("LEFT JOIN #{TimeEntry.table_name} ON #{TimeEntry.table_name}.issue_id = #{Issue.table_name}.id").
sum("#{TimeEntry.table_name}.hours").to_f || 0.0
if leaf?
spent_hours
else
@total_spent_hours ||=
self_and_descendants.joins(:time_entries).sum("#{TimeEntry.table_name}.hours").to_f || 0.0
end
end
def total_estimated_hours