a simple model for mapping closed issues into a chart

This commit is contained in:
Radek Stepan 2013-08-15 15:25:42 +01:00
parent eba859bcbc
commit b36f11846b
5 changed files with 31 additions and 5 deletions

View File

@ -3,10 +3,6 @@
[ ![Codeship Status for radekstepan/github-burndown-chart](https://www.codeship.io/projects/d69f4420-e5b0-0130-bbae-1632ddfb80f8/status?branch=rework)](https://www.codeship.io/projects/5855)
##Next
Map closed tasks to a range of dates while maintaining the points remaining stats.
##Project Charter
The app is to display a burndown chart from a set of GitHub issues in a milestone.

9
src/chart.coffee Normal file
View File

@ -0,0 +1,9 @@
#!/usr/bin/env coffee
{ _ } = require 'lodash'
module.exports =
# Map closed issues ready to be visualized.
# Assumes collection has been `filter`ed and is ordered.
'closed': (collection, total, cb) ->
cb null, _.map collection, ({ closed_at, size }) ->
{ x: +new Date(closed_at), y: total -= size }

View File

@ -4,6 +4,7 @@ async = require 'async'
req = require './request'
reg = require './regex'
dates = require './dates'
module.exports =
# Used on an initial fetch of issues for a repo.

20
test/chart.coffee Normal file
View File

@ -0,0 +1,20 @@
#!/usr/bin/env coffee
assert = require 'assert'
path = require 'path'
chart = require path.resolve __dirname, '../src/chart.coffee'
module.exports =
'chartize closed issues': (done) ->
a = { number: 2, closed_at: '2013-05-09T09:04:53Z', size: 6 }
b = { number: 1, closed_at: '2013-05-09T10:04:53Z', size: 4 }
c = { number: 3, closed_at: '2013-05-12T09:04:53Z', size: 2 }
chart.closed [ a, b, c ], 20, (err, data) ->
assert.ifError err
assert.deepEqual data, [
{ x: 1368090293000, y: 14 }
{ x: 1368093893000, y: 10 }
{ x: 1368349493000, y: 8 }
]
done.call null

View File

@ -8,7 +8,7 @@ req = {}
issues = proxy path.resolve(__dirname, '../src/issues.coffee'),
'./request': req
module.exports =
module.exports =
'all empty': (done) ->
called = 0
req.all_issues = (opts, cb) ->