From 0634fbc604c5a7a024454041e21183e580ca7fc9 Mon Sep 17 00:00:00 2001 From: Radek Stepan Date: Fri, 25 May 2012 13:39:31 +0100 Subject: [PATCH] dealing with non working weekends; closes #6 --- README.md | 2 +- app.coffee | 23 ++++++++++++++++------- templates/burndown.eco | 4 +++- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index d6f961e..4c421ed 100644 --- a/README.md +++ b/README.md @@ -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: diff --git a/app.coffee b/app.coffee index 73f05a1..2393fdb 100644 --- a/app.coffee +++ b/app.coffee @@ -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', diff --git a/templates/burndown.eco b/templates/burndown.eco index b618427..fc4bc5f 100644 --- a/templates/burndown.eco +++ b/templates/burndown.eco @@ -66,6 +66,8 @@