From 8760d0721596ae7ea87a2e4cc33f9a35167d2d42 Mon Sep 17 00:00:00 2001 From: Tyler Renelle Date: Sat, 3 Aug 2013 14:06:57 -0400 Subject: [PATCH] apiv2 fix to pending op (@litenull) --- src/server/apiv2.coffee | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/server/apiv2.coffee b/src/server/apiv2.coffee index 80aa725519..a538ff8f52 100644 --- a/src/server/apiv2.coffee +++ b/src/server/apiv2.coffee @@ -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