Permalink
Browse files

Fixed the Predict caculate bug

  • Loading branch information...
zigzag committed Jan 25, 2010
1 parent b2af49d commit 6b822176e67cb7dd9c126e97119b0cf801407d6f
Showing with 7 additions and 4 deletions.
  1. +7 −4 app/models/enhanced_burndown_chart.rb
@@ -20,14 +20,14 @@ def insight_data
end
def todo_data
- (first_entry_date..latest_entry_date).inject([]) do |todo_data, date|
+ (first_entry_date..(latest_entry_date)).inject([]) do |todo_data, date|
todo_data << DateHoursPair.new(date,sum_up_hours(:todo_hours_till,date))
end
end
def predict_data
predict_data = []
- return predict_data if velocity <= 0 # unpredictable
+ return predict_data if (!velocity.finite? || velocity <= 0 || latest_date_todo_hours<=0) # unpredictable
date = latest_entry_date
todo = latest_date_todo_hours
begin
@@ -48,7 +48,7 @@ def sum_up_hours(hours_method,till_date)
all_issues.sum { |issue| issue.send(hours_method,till_date)}
end
def count_working_days(from,to)
- (from..to).reject { |d| [0,6].include? d.wday }.count
+ (from...to).reject { |d| [0,6].include? d.wday }.count
end
def start_date
@@ -61,7 +61,10 @@ def first_entry_date
@first_entry_date ||= (all_issues.map(&:latest_entry_date).compact.sort.first || start_date)
end
def latest_entry_date
- @latest_entry_date ||= all_issues.map(&:latest_entry_date).compact.sort.last || start_date
+ return @latest_entry_date if @latest_entry_date
+ entried_date = all_issues.map(&:latest_entry_date).compact.sort.last
+ @latest_entry_date = (entried_date)? (entried_date + 1.day) : start_date
+ return @latest_entry_date
end
def first_date_todo_hours
@first_date_todo_hours ||= sum_up_hours(:todo_hours_till,first_entry_date)

0 comments on commit 6b82217

Please sign in to comment.