apiv2 fix to pending op (@litenull)

This commit is contained in:
Tyler Renelle 2013-08-03 14:06:57 -04:00
parent 9e2ef95d84
commit 8760d07215

View file

@ -28,8 +28,9 @@ router.post '/', api.auth, (req, res, next) ->
{user} = req
actions = req.body
doneCount = 1 + # cron
actions.length # standard operations
_.size(actions) # standard operations
done = (err) ->
return next(err) if err
if --doneCount is 0
@ -42,6 +43,8 @@ router.post '/', api.auth, (req, res, next) ->
res.json 200, uObj
console.log "Reply sent"
if _.isObject(actions) and _.isEmpty(actions) then done() # first request, empty object
misc.batchTxn model, (uObj, paths) ->
# habitrpg-shared/algos requires uObj.habits, uObj.dailys etc instead of uObj.tasks
_.each ['habit','daily','todo','reward'], (type) -> uObj["#{type}s"] = _.where(uObj.tasks, {type}); true