fix project results order, sort by time

This commit is contained in:
Brian Gough 2015-02-16 13:43:11 +00:00
parent 3ab8238013
commit 8615b7a086

View file

@ -154,6 +154,9 @@ module.exports = MongoPackManager =
return false if cutoff? && ts < cutoff return false if cutoff? && ts < cutoff
return true return true
timeOrder = (a, b) ->
b.meta.end_ts - a.meta.end_ts
updates = MongoPackManager._filterAndLimit(updates, unpackedSet, filterFn, limit) updates = MongoPackManager._filterAndLimit(updates, unpackedSet, filterFn, limit)
#console.log 'initial updates are', updates #console.log 'initial updates are', updates
@ -210,15 +213,15 @@ module.exports = MongoPackManager =
tail.toArray (err, result2) -> tail.toArray (err, result2) ->
if err? if err?
return callback err, updates return callback err, updates.sort timeOrder
else else
applyAndUpdate result2 applyAndUpdate result2
overlap.toArray (err, result3) -> overlap.toArray (err, result3) ->
if err? if err?
return callback err, updates return callback err, updates.sort timeOrder
else else
applyAndUpdate result3 applyAndUpdate result3
callback err, updates callback err, updates.sort timeOrder
_unpackResults: (updates) -> _unpackResults: (updates) ->
# iterate over the updates, if there's a pack, expand it into ops and # iterate over the updates, if there's a pack, expand it into ops and