Created
July 27, 2009 23:15
-
-
Save edavis10/156816 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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