mirror of
https://github.com/meineerde/redmine.git
synced 2025-12-19 15:01:14 +00:00
Code cleanup.
git-svn-id: http://svn.redmine.org/redmine/trunk@14274 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
31bffaa053
commit
5e28f0b1b6
@ -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
|
||||
if leaf?
|
||||
spent_hours
|
||||
else
|
||||
@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
|
||||
self_and_descendants.joins(:time_entries).sum("#{TimeEntry.table_name}.hours").to_f || 0.0
|
||||
end
|
||||
end
|
||||
|
||||
def total_estimated_hours
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user