back to obj

This commit is contained in:
Radek Stepan 2013-08-13 17:23:22 +01:00
parent e552e38b8a
commit 34c0ea2832
2 changed files with 7 additions and 13 deletions

View File

@ -61,7 +61,7 @@ module.exports =
# 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.
'into_days': (collection, regex, cb) ->
days = [] ; current = [ -1, null ]
days = {}
for issue in collection
{ state, number, closed_at } = issue
number ?= '?'
@ -71,13 +71,8 @@ module.exports =
# Explode the matches.
[ date, time ] = matches[1...]
# Move the index?
if current[1] isnt date
current[0] += 1
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
# Save it.
days[date] ?= []
days[date].push issue
cb null, days

View File

@ -191,8 +191,7 @@ module.exports =
issues.into_days [ a, b, c ], /size (\d+)$/, (err, data) ->
assert.ifError err
assert.deepEqual data, [
{ date: '2013-05-09', issues: [ a, b ] }
{ date: '2013-05-10', issues: [ c ] }
]
assert.deepEqual data,
'2013-05-09': [ a, b ]
'2013-05-10': [ c ]
done.call null