diff --git a/app/models/burndown_day.rb b/app/models/burndown_day.rb index 20a2954c1..699cf1913 100755 --- a/app/models/burndown_day.rb +++ b/app/models/burndown_day.rb @@ -7,12 +7,19 @@ def self.points_committed(backlog) backlog.inject(0) {|sum, story| sum + story.story_points.to_f } end - # number of points already resolved (counting tasks) + # number of points already resolved (story tasks closed) def self.points_resolved(backlog) - backlog.select {|s| s.descendants.select{|t| !t.closed?}.size == 0}.inject(0) {|sum, story| sum + story.story_points.to_f } + backlog.select do |s| + if s.descendants.empty? + # sometimes a story is too small to split it up into tasks + s.closed? + else + s.descendants.select{|t| !t.closed?}.size == 0 + end + end.inject(0) {|sum, story| sum + story.story_points.to_f } end - # number of points already resolved (only counting stories) + # number of points already resolved (stories closed) def self.points_accepted(backlog) backlog.select {|s| s.closed? }.inject(0) {|sum, story| sum + story.story_points.to_f } end diff --git a/lib/backlogs_issue_patch.rb b/lib/backlogs_issue_patch.rb index ac500e653..eeb568a7c 100755 --- a/lib/backlogs_issue_patch.rb +++ b/lib/backlogs_issue_patch.rb @@ -101,7 +101,7 @@ def recalculate_attributes_for_with_remaining_hours(issue_id) def backlogs_before_validation return unless self.project.module_enabled? 'backlogs' - if self.tracker_id == Task.tracker + if self.tracker_id == Task.tracker || self.descendants.empty? self.estimated_hours = self.remaining_hours if self.estimated_hours.blank? && ! self.remaining_hours.blank? self.remaining_hours = self.estimated_hours if self.remaining_hours.blank? && ! self.estimated_hours.blank? end