Merge branch 'fix-prefer-milestone-with-duedate' of git://github.com/jhnns/github-burndown-chart into jhnns-fix-prefer-milestone-with-duedate
Conflicts: src/modules/milestones.coffee
This commit is contained in:
commit
e210bf3f33
|
@ -29333,14 +29333,16 @@ module.exports = {
|
||||||
fn = function(x) {
|
fn = function(x) {
|
||||||
return slope * x + intercept;
|
return slope * x + intercept;
|
||||||
};
|
};
|
||||||
a = +new Date(created_at) - start;
|
created_at = new Date(created_at);
|
||||||
b = +new Date(due_on) - start;
|
due_on = due_on ? new Date(due_on) : new Date();
|
||||||
|
a = created_at - start;
|
||||||
|
b = due_on - start;
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
date: new Date(created_at),
|
date: created_at,
|
||||||
points: fn(a)
|
points: fn(a)
|
||||||
}, {
|
}, {
|
||||||
date: new Date(due_on),
|
date: due_on,
|
||||||
points: fn(b)
|
points: fn(b)
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
@ -29508,7 +29510,9 @@ module.exports = {
|
||||||
|
|
||||||
});
|
});
|
||||||
require.register("app/modules/milestones.js", function(exports, require, module){
|
require.register("app/modules/milestones.js", function(exports, require, module){
|
||||||
var marked, request;
|
var marked, request, _;
|
||||||
|
|
||||||
|
_ = require('lodash')._;
|
||||||
|
|
||||||
marked = require('marked');
|
marked = require('marked');
|
||||||
|
|
||||||
|
@ -29528,6 +29532,10 @@ module.exports = {
|
||||||
return cb(null, "No open milestones for repo " + repo.path);
|
return cb(null, "No open milestones for repo " + repo.path);
|
||||||
}
|
}
|
||||||
m = data[0];
|
m = data[0];
|
||||||
|
m = _.rest(data, {
|
||||||
|
'due_on': null
|
||||||
|
});
|
||||||
|
m = m[0] ? m[0] : data[0];
|
||||||
if (m.open_issues + m.closed_issues === 0) {
|
if (m.open_issues + m.closed_issues === 0) {
|
||||||
return cb(null, "No issues for milestone " + m.title);
|
return cb(null, "No issues for milestone " + m.title);
|
||||||
}
|
}
|
||||||
|
|
|
@ -101,15 +101,20 @@ module.exports =
|
||||||
intercept = (e - (slope * b1)) / l
|
intercept = (e - (slope * b1)) / l
|
||||||
fn = (x) -> slope * x + intercept
|
fn = (x) -> slope * x + intercept
|
||||||
|
|
||||||
a = +new Date(created_at) - start
|
# Milestone always has a creation date.
|
||||||
b = +new Date(due_on) - start
|
created_at = new Date created_at
|
||||||
|
# Due date can be empty.
|
||||||
|
due_on = if due_on then new Date(due_on) else new Date()
|
||||||
|
|
||||||
|
a = created_at - start
|
||||||
|
b = due_on - start
|
||||||
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
date: new Date(created_at)
|
date: created_at
|
||||||
points: fn(a)
|
points: fn(a)
|
||||||
}, {
|
}, {
|
||||||
date: new Date(due_on)
|
date: due_on
|
||||||
points: fn(b)
|
points: fn(b)
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#!/usr/bin/env coffee
|
#!/usr/bin/env coffee
|
||||||
|
{ _ } = require 'lodash'
|
||||||
marked = require 'marked'
|
marked = require 'marked'
|
||||||
|
|
||||||
request = require './request'
|
request = require './request'
|
||||||
|
@ -16,6 +17,10 @@ module.exports =
|
||||||
return cb null, "No open milestones for repo #{repo.path}" unless data.length
|
return cb null, "No open milestones for repo #{repo.path}" unless data.length
|
||||||
# The first milestone should be ending soonest.
|
# The first milestone should be ending soonest.
|
||||||
m = data[0]
|
m = data[0]
|
||||||
|
# Filter milestones without due date.
|
||||||
|
m = _.rest data, { 'due_on' : null }
|
||||||
|
# The first milestone should be ending soonest. Prefer milestones with due dates.
|
||||||
|
m = if m[0] then m[0] else data[0]
|
||||||
# Empty milestone?
|
# Empty milestone?
|
||||||
return cb null, "No issues for milestone #{m.title}" if m.open_issues + m.closed_issues is 0
|
return cb null, "No issues for milestone #{m.title}" if m.open_issues + m.closed_issues is 0
|
||||||
# Has description? Parse GFM.
|
# Has description? Parse GFM.
|
||||||
|
|
|
@ -25,6 +25,21 @@ module.exports =
|
||||||
assert.equal milestone.number, 1
|
assert.equal milestone.number, 1
|
||||||
do done
|
do done
|
||||||
|
|
||||||
|
'milestones - get current from 1 when milestone has no due date': (done) ->
|
||||||
|
req.all_milestones = (opts, cb) ->
|
||||||
|
cb null, [
|
||||||
|
{
|
||||||
|
'number': 1
|
||||||
|
'created_at': '2013-01-01T00:00:00Z'
|
||||||
|
'due_on': null
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
milestones.get_current {}, (err, warn, milestone) ->
|
||||||
|
assert.ifError err
|
||||||
|
assert.equal milestone.number, 1
|
||||||
|
do done
|
||||||
|
|
||||||
# We always take from head because of request params.
|
# We always take from head because of request params.
|
||||||
'milestones - get current from > 1': (done) ->
|
'milestones - get current from > 1': (done) ->
|
||||||
req.all_milestones = (opts, cb) ->
|
req.all_milestones = (opts, cb) ->
|
||||||
|
@ -51,11 +66,36 @@ module.exports =
|
||||||
assert.equal milestone.number, 2
|
assert.equal milestone.number, 2
|
||||||
do done
|
do done
|
||||||
|
|
||||||
|
'milestones - get current from > 1 when there are milestones without due date': (done) ->
|
||||||
|
req.all_milestones = (opts, cb) ->
|
||||||
|
cb null, [
|
||||||
|
{
|
||||||
|
'number': 2
|
||||||
|
'created_at': '2013-01-01T00:00:00Z'
|
||||||
|
'due_on': null
|
||||||
|
}
|
||||||
|
{
|
||||||
|
'number': 1
|
||||||
|
'created_at': '2013-01-01T00:00:00Z'
|
||||||
|
'due_on': '2013-02-01T00:00:00Z'
|
||||||
|
}
|
||||||
|
{
|
||||||
|
'number': 3
|
||||||
|
'created_at': '2013-01-01T00:00:00Z'
|
||||||
|
'due_on': '2013-02-15T00:00:00Z'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
milestones.get_current {}, (err, warn, milestone) ->
|
||||||
|
assert.ifError err
|
||||||
|
assert.equal milestone.number, 1
|
||||||
|
do done
|
||||||
|
|
||||||
'milestones - get current when empty': (done) ->
|
'milestones - get current when empty': (done) ->
|
||||||
req.all_milestones = (opts, cb) ->
|
req.all_milestones = (opts, cb) ->
|
||||||
cb null, []
|
cb null, []
|
||||||
|
|
||||||
milestones.get_current { path: 'some/repo' }, (err, warn, milestone) ->
|
milestones.get_current { 'path': 'some/repo' }, (err, warn, milestone) ->
|
||||||
assert.ifError err
|
assert.ifError err
|
||||||
assert.equal warn, 'No open milestones for repo some/repo'
|
assert.equal warn, 'No open milestones for repo some/repo'
|
||||||
do done
|
do done
|
||||||
|
|
Loading…
Reference in New Issue