From 8c7caaa3cc7dde5fdf23814347f1e9dedfc261eb Mon Sep 17 00:00:00 2001 From: Radek Stepan Date: Sat, 20 Sep 2014 11:45:28 -0700 Subject: [PATCH] no due date milestones are always on track --- README.md | 3 ++- public/js/app.bundle.js | 14 +++++++++++++- public/js/app.js | 14 +++++++++++++- src/templates/projects.mustache | 2 +- src/utils/format.coffee | 8 ++++++++ 5 files changed, 37 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 3aee57f..223da4c 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ GitHub Burndown Chart as a service. Public repos are free, for private access au ### The 20% -- [ ] deal with no due date milestones - always on track +- [ ] progress needs to be calculated based on strategy even on homepage - [ ] be able to go back to homepage - [ ] calculate left margin based on the total number of points text width - [ ] Do not show login/logged-in state when we are still fetching that information from Firebase @@ -25,6 +25,7 @@ GitHub Burndown Chart as a service. Public repos are free, for private access au - [ ] Check that we have not run out of requests to make - [ ] Show loading sign on top of [browser window](https://github.com/buunguyen/topbar) which is unobtrusive enough we can show it immediately. - [ ] show a countdown clock towards the end of the milestone or show overdue +- [x] deal with no due date milestones - always on track - [x] show title on the chart page - [x] work for `mbostock/d3` - [x] allow people to go straight to a URL that fetches the repo, if public, for them; to demo our app without adding a repo (add it behind the scenes); *req* cache repos diff --git a/public/js/app.bundle.js b/public/js/app.bundle.js index 5d635de..c096c2e 100644 --- a/public/js/app.bundle.js +++ b/public/js/app.bundle.js @@ -40748,7 +40748,7 @@ if (typeof exports === 'object') { // projects.mustache root.require.register('burnchart/src/templates/projects.js', function(exports, require, module) { - module.exports = ["{{#projects.list.length}}","
","
"," Sorted by priority","

Projects

","
",""," "," {{#projects.list}}"," {{#milestones}}"," "," "," "," "," "," {{/milestones}}"," {{/projects.list}}",""," ","
{{owner}}/{{name}}"," {{ title }}"," ","
"," {{Math.floor(format.progress(closed_issues, open_issues))}}%"," {{format.due(due_on)}}","
","
","
","
","
","","
"," Edit","
","
","{{/projects.list}}"].join("\n"); + module.exports = ["{{#projects.list.length}}","
","
"," Sorted by priority","

Projects

","
",""," "," {{#projects.list}}"," {{#milestones}}"," "," "," "," "," "," {{/milestones}}"," {{/projects.list}}",""," ","
{{owner}}/{{name}}"," {{ title }}"," ","
"," {{Math.floor(format.progress(closed_issues, open_issues))}}%"," {{{ format.due(due_on) }}}","
","
","
","
","
","","
"," Edit","
","
","{{/projects.list}}"].join("\n"); }); // date.coffee @@ -40765,23 +40765,35 @@ if (typeof exports === 'object') { // format.coffee root.require.register('burnchart/src/utils/format.js', function(exports, require, module) { + var config; + + config = require('../models/config'); + module.exports = { 'progress': _.memoize(function(a, b) { return 100 * (a / (b + a)); }), 'onTime': _.memoize(function(milestone) { var a, b, c, points, time; + if (!milestone.due_on) { + return 'green'; + } points = this.progress(milestone.closed_issues, milestone.open_issues); a = +new Date(milestone.created_at); b = +(new Date); c = +new Date(milestone.due_on); time = this.progress(b - a, c - b); return ['red', 'green'][+(points > time)]; + }, function(m) { + return [m.created_at, m.number].join('/'); }), 'fromNow': _.memoize(function(jsonDate) { return moment(new Date(jsonDate)).fromNow(); }), 'due': function(jsonDate) { + if (!jsonDate) { + return ' '; + } return ['due', this.fromNow(jsonDate)].join(' '); }, 'markdown': function(markup) { diff --git a/public/js/app.js b/public/js/app.js index e928665..e8749f0 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -782,7 +782,7 @@ // projects.mustache root.require.register('burnchart/src/templates/projects.js', function(exports, require, module) { - module.exports = ["{{#projects.list.length}}","
","
"," Sorted by priority","

Projects

","
",""," "," {{#projects.list}}"," {{#milestones}}"," "," "," "," "," "," {{/milestones}}"," {{/projects.list}}",""," ","
{{owner}}/{{name}}"," {{ title }}"," ","
"," {{Math.floor(format.progress(closed_issues, open_issues))}}%"," {{format.due(due_on)}}","
","
","
","
","
","","
"," Edit","
","
","{{/projects.list}}"].join("\n"); + module.exports = ["{{#projects.list.length}}","
","
"," Sorted by priority","

Projects

","
",""," "," {{#projects.list}}"," {{#milestones}}"," "," "," "," "," "," {{/milestones}}"," {{/projects.list}}",""," ","
{{owner}}/{{name}}"," {{ title }}"," ","
"," {{Math.floor(format.progress(closed_issues, open_issues))}}%"," {{{ format.due(due_on) }}}","
","
","
","
","
","","
"," Edit","
","
","{{/projects.list}}"].join("\n"); }); // date.coffee @@ -799,23 +799,35 @@ // format.coffee root.require.register('burnchart/src/utils/format.js', function(exports, require, module) { + var config; + + config = require('../models/config'); + module.exports = { 'progress': _.memoize(function(a, b) { return 100 * (a / (b + a)); }), 'onTime': _.memoize(function(milestone) { var a, b, c, points, time; + if (!milestone.due_on) { + return 'green'; + } points = this.progress(milestone.closed_issues, milestone.open_issues); a = +new Date(milestone.created_at); b = +(new Date); c = +new Date(milestone.due_on); time = this.progress(b - a, c - b); return ['red', 'green'][+(points > time)]; + }, function(m) { + return [m.created_at, m.number].join('/'); }), 'fromNow': _.memoize(function(jsonDate) { return moment(new Date(jsonDate)).fromNow(); }), 'due': function(jsonDate) { + if (!jsonDate) { + return ' '; + } return ['due', this.fromNow(jsonDate)].join(' '); }, 'markdown': function(markup) { diff --git a/src/templates/projects.mustache b/src/templates/projects.mustache index 2153b04..e3dc036 100644 --- a/src/templates/projects.mustache +++ b/src/templates/projects.mustache @@ -16,7 +16,7 @@
{{Math.floor(format.progress(closed_issues, open_issues))}}% - {{format.due(due_on)}} + {{{ format.due(due_on) }}}
diff --git a/src/utils/format.coffee b/src/utils/format.coffee index ca19f57..14eb0bd 100644 --- a/src/utils/format.coffee +++ b/src/utils/format.coffee @@ -1,3 +1,5 @@ +config = require '../models/config' + module.exports = # Progress in percentages. @@ -6,6 +8,9 @@ module.exports = # Is a milestone on time? 'onTime': _.memoize (milestone) -> + # Milestones with no due date are always on track. + return 'green' unless milestone.due_on + # Progress in points. points = @progress milestone.closed_issues, milestone.open_issues @@ -18,6 +23,8 @@ module.exports = time = @progress b - a, c - b [ 'red', 'green' ][ +(points > time) ] + , (m) -> # resolver + [ m.created_at, m.number ].join '/' # Time from now. 'fromNow': _.memoize (jsonDate) -> @@ -25,6 +32,7 @@ module.exports = # When is a milestone due? 'due': (jsonDate) -> + return ' ' unless jsonDate [ 'due', @fromNow jsonDate ].join(' ') # Markdown formatting.