Skip to content

Commit

Permalink
sometimes my stories just don’t have any tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
maser committed Apr 21, 2011
1 parent 66c0ca5 commit 609d11f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
13 changes: 10 additions & 3 deletions app/models/burndown_day.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/backlogs_issue_patch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 609d11f

Please sign in to comment.