dealing with non working weekends; closes #6

This commit is contained in:
Radek Stepan 2012-05-25 13:39:31 +01:00
parent d840c26c4b
commit 0634fbc604
3 changed files with 20 additions and 9 deletions

View File

@ -27,7 +27,7 @@ Then, assign tickets to milestones and add labels to them in the format **size n
## Use:
1. Start a node server using `.webserver.sh`.
1. Start a node server using `.webserver.sh`
2. Visit [http://0.0.0.0:3000/](http://0.0.0.0:3000/)
## Example:

View File

@ -101,11 +101,19 @@ app.get '/burndown', (req, res) ->
current.milestone = milestone ; current.diff = diff ; current.due = due
# Create n dict with all dates in the milestone span.
days = {} ; totalDays = 0
days = {} ; totalDays = 0 ; totalNonWorkingDays = 0
day = Issues.dateToTime current.milestone.created_at
while day < current.due
# Save the day.
days[day] = { 'issues': [], 'actual': 0, 'ideal': 0 }
# Is this a weekend?
dayOfWeek = new Date(day).getDay()
if dayOfWeek is 6 or dayOfWeek is 0
totalNonWorkingDays += 1
# Save the day.
days[day] = { 'issues': [], 'actual': 0, 'ideal': 0, 'weekend': true }
else
# Save the day.
days[day] = { 'issues': [], 'actual': 0, 'ideal': 0, 'weekend': false }
# Shift by a day.
day += 1000 * 60 * 60 * 24
# Increase the total count.
@ -131,7 +139,7 @@ app.get '/burndown', (req, res) ->
days[Issues.dateToTime issue.closed_at]['issues'].push issue
# Calculate the predicted daily velocity.
dailyIdeal = current['size'] / totalDays ; ideal = current['size']
dailyIdeal = current['size'] / (totalDays - totalNonWorkingDays) ; ideal = current['size']
# Go through the days and save the number of outstanding issues size.
for day, d of days
@ -140,9 +148,10 @@ app.get '/burndown', (req, res) ->
current['size'] -= issue.size
# Save the oustanding count for that day.
days[day].actual = current['size']
# Save the predicted velocity for that day.
ideal -= dailyIdeal
days[day].ideal = ideal # preserve the accurateness so we get a straight line
# Save the predicted velocity for that day if it is not a non-working day.
ideal -= dailyIdeal unless days[day].weekend
days[day].ideal = ideal
# Finally send to client.
res.render 'burndown',

View File

@ -66,6 +66,8 @@
<script>
(function() {
var now = new Date().getTime();
var ideal = [], actual = [], issues = {}, i = 0;
<% for day, data of @days: %>
ideal.push({ 'x': <%= day / 1000 %>, 'y': <%= data['ideal'] %> });
@ -146,7 +148,7 @@
element: document.getElementById('timeline')
});
annotator.add(new Date().getTime() / 1000, 'Now');
annotator.add(now / 1000, 'Now');
annotator.update();
})();
</script>