back to obj
This commit is contained in:
parent
e552e38b8a
commit
34c0ea2832
|
@ -61,7 +61,7 @@ module.exports =
|
||||||
# Map a collection of closed issues into days and determine the velocity for the range of all days.
|
# Map a collection of closed issues into days and determine the velocity for the range of all days.
|
||||||
# Assumes collection has been `filter`ed and is ordered.
|
# Assumes collection has been `filter`ed and is ordered.
|
||||||
'into_days': (collection, regex, cb) ->
|
'into_days': (collection, regex, cb) ->
|
||||||
days = [] ; current = [ -1, null ]
|
days = {}
|
||||||
for issue in collection
|
for issue in collection
|
||||||
{ state, number, closed_at } = issue
|
{ state, number, closed_at } = issue
|
||||||
number ?= '?'
|
number ?= '?'
|
||||||
|
@ -71,13 +71,8 @@ module.exports =
|
||||||
|
|
||||||
# Explode the matches.
|
# Explode the matches.
|
||||||
[ date, time ] = matches[1...]
|
[ date, time ] = matches[1...]
|
||||||
# Move the index?
|
# Save it.
|
||||||
if current[1] isnt date
|
days[date] ?= []
|
||||||
current[0] += 1
|
days[date].push issue
|
||||||
current[1] = date
|
|
||||||
# Init the array position.
|
|
||||||
days[current[0]] = { 'date': date, 'issues': [] }
|
|
||||||
# Save it assuming coll is in order.
|
|
||||||
days[current[0]].issues.push issue
|
|
||||||
|
|
||||||
cb null, days
|
cb null, days
|
|
@ -191,8 +191,7 @@ module.exports =
|
||||||
|
|
||||||
issues.into_days [ a, b, c ], /size (\d+)$/, (err, data) ->
|
issues.into_days [ a, b, c ], /size (\d+)$/, (err, data) ->
|
||||||
assert.ifError err
|
assert.ifError err
|
||||||
assert.deepEqual data, [
|
assert.deepEqual data,
|
||||||
{ date: '2013-05-09', issues: [ a, b ] }
|
'2013-05-09': [ a, b ]
|
||||||
{ date: '2013-05-10', issues: [ c ] }
|
'2013-05-10': [ c ]
|
||||||
]
|
|
||||||
done.call null
|
done.call null
|
Loading…
Reference in New Issue