summaryrefslogtreecommitdiffstats
path: root/app/models/issue.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/issue.rb')
-rw-r--r--app/models/issue.rb16
1 files changed, 9 insertions, 7 deletions
diff --git a/app/models/issue.rb b/app/models/issue.rb
index 2944031ac..85c3ff871 100644
--- a/app/models/issue.rb
+++ b/app/models/issue.rb
@@ -206,6 +206,7 @@ class Issue < ActiveRecord::Base
@assignable_versions = nil
@relations = nil
@spent_hours = nil
+ @total_estimated_hours = nil
base_reload(*args)
end
@@ -435,9 +436,6 @@ class Issue < ActiveRecord::Base
if done_ratio_derived?
names -= %w(done_ratio)
end
- unless leaf?
- names -= %w(estimated_hours)
- end
names
end
@@ -929,6 +927,14 @@ class Issue < ActiveRecord::Base
sum("#{TimeEntry.table_name}.hours").to_f || 0.0
end
+ def total_estimated_hours
+ if leaf?
+ estimated_hours
+ else
+ @total_estimated_hours ||= self_and_descendants.sum(:estimated_hours)
+ end
+ end
+
def relations
@relations ||= IssueRelation::Relations.new(self, (relations_from + relations_to).sort)
end
@@ -1488,10 +1494,6 @@ class Issue < ActiveRecord::Base
end
end
- # estimate = sum of leaves estimates
- p.estimated_hours = p.leaves.sum(:estimated_hours).to_f
- p.estimated_hours = nil if p.estimated_hours == 0.0
-
# ancestors will be recursively updated
p.save(:validate => false)
end