Skip to content

Instantly share code, notes, and snippets.

@edavis10
Created July 27, 2009 23:15
Show Gist options
  • Save edavis10/156816 to your computer and use it in GitHub Desktop.
Save edavis10/156816 to your computer and use it in GitHub Desktop.
def total_hours_for_issue_for_date_range(issue, user, date_from, date_to)
- current_date = date_from
- total = 0.0
- while current_date <= date_to
- hours = total_hours_for_user_on_day(issue, user, current_date)
- total += hours unless hours.nil?
- current_date += 1
- end
- total
+ (date_from.to_date..date_to).inject(0.0) {|sum, day|
+ hours = total_hours_for_user_on_day(issue, user, day)
+ sum += hours unless hours.nil?
+ sum
+ }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment