fix empty milestones div by 0

This commit is contained in:
Radek Stepan 2014-10-27 20:26:22 -06:00
parent bd9a43e1a9
commit 391adb5388
3 changed files with 21 additions and 8 deletions

View File

@ -1,5 +1,6 @@
#Tasks to do
- [ ] success/warn topbar on milestone page is only shown if we async load data
- [ ] create notes about how original people can upgrade to burnchart
- [ ] clean up docs, track them on git or using Assembly system?
- [ ] rename repo to burnchart
@ -14,12 +15,12 @@
##Next Release
- [ ] https://github.com/medic/medic-webapp project is overdue and trendline & ideal line end on that date; should max on that date or today's date
- [*] https://github.com/ractivejs/ractive gives me NaN for a milestone progress %
- [ ] http://burnchart.io#rails I would expect it to list all the projects for that owner so I can select one of them (Ryan)
- [ ] why didn't Reset DB load demo data? (Ryan)
##Backlog
- [ ] be able to specify milestone by name (will nicely show in title)
- [ ] focus on form fields style (blue outline etc)
- [ ] switch off `user-select` on buttons
- [ ] make async pages transition so that there is no "jumping" on the page
@ -30,7 +31,6 @@
- [ ] responsive layout
- [ ] show project name on the milestone page, in the title
- [ ] conctact the people that have starred the original burndown chart telling them about the repo; keep track of connects via a tiny crm/spreadsheet and use a custom email address like radek@burnchart.io
- [ ] success/warn topbar on milestone page is only shown if we async load data
- [ ] html entities (like & at the bottom of the page) are not being rendered correctly; {{{}}} ?
- [ ] `rails/rails/24` has issues in two clusters as if merged from two milestones
- [ ] trendline cutting into axes

View File

@ -1,19 +1,24 @@
moment = require 'moment'
# Progress in %.
progress = (a, b) -> 100 * (a / (b + a))
progress = (a, b) ->
if a + b is 0 then 0 else 100 * (a / (b + a))
# Calculate the stats for a milestone.
# Is it on time? What is the progress?
module.exports = (milestone) ->
isDone = no ; isOnTime = yes ; isOverdue = no
isDone = no ; isOnTime = yes ; isOverdue = no ; isEmpty = yes; points = 0
# Progress in points.
points = progress milestone.issues.closed.size, milestone.issues.open.size
a = milestone.issues.closed.size
b = milestone.issues.open.size
if a + b > 0
isEmpty = no
points = progress a, b
isDone = yes if points is 100
# Milestones with no due date are always on track.
return { isOverdue, isOnTime, isDone, 'progress': { points } } unless milestone.due_on
return { isOverdue, isOnTime, isDone, isEmpty, 'progress': { points } } unless milestone.due_on
a = +new Date milestone.created_at
b = +new Date

View File

@ -66,6 +66,14 @@ module.exports = Eventful.extend
# Save the milestone with issues.
projects.addMilestone project, data
# No issues?
return @publish '!app/notify', {
'text': 'The milestone has no issues'
'type': 'warn'
'system': yes
'ttl': null
} if data.stats.isEmpty
# Done?
@publish '!app/notify', {
'text': 'The milestone is complete'