mirror of
https://github.com/meineerde/redmine.git
synced 2025-12-19 23:11:12 +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
|
@assignable_versions = nil
|
||||||
@relations = nil
|
@relations = nil
|
||||||
@spent_hours = nil
|
@spent_hours = nil
|
||||||
|
@total_spent_hours = nil
|
||||||
@total_estimated_hours = nil
|
@total_estimated_hours = nil
|
||||||
base_reload(*args)
|
base_reload(*args)
|
||||||
end
|
end
|
||||||
@ -916,15 +917,13 @@ class Issue < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Returns the total number of hours spent on this issue and its descendants
|
# 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
|
def total_spent_hours
|
||||||
|
if leaf?
|
||||||
|
spent_hours
|
||||||
|
else
|
||||||
@total_spent_hours ||=
|
@total_spent_hours ||=
|
||||||
self_and_descendants.
|
self_and_descendants.joins(:time_entries).sum("#{TimeEntry.table_name}.hours").to_f || 0.0
|
||||||
joins("LEFT JOIN #{TimeEntry.table_name} ON #{TimeEntry.table_name}.issue_id = #{Issue.table_name}.id").
|
end
|
||||||
sum("#{TimeEntry.table_name}.hours").to_f || 0.0
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def total_estimated_hours
|
def total_estimated_hours
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user