forgot to start transcation for cron

This commit is contained in:
Tyler Renelle 2013-02-02 13:59:05 -05:00
parent ba10f7943d
commit 4c5b8aacab
2 changed files with 3 additions and 3 deletions

View file

@ -80,8 +80,7 @@ module.exports.BatchUpdate = BatchUpdate = (model) ->
# many cases, userObj.tasks.{taskId}.value is undefined - so we manually .get() each attribute here.
# Additionally, for some reason after getting the user object, changing properies manually (userObj.stats.hp = 50)
# seems to actually run user.set('stats.hp',50) which we don't want to do - so we deepClone here
#_.each Object.keys(userSchema), (key) -> userObj[key] = lodash.cloneDeep user.get(key)
#userObj = user.get()
_.each Object.keys(userSchema), (key) -> userObj[key] = lodash.cloneDeep user.get(key)
model._commit = (txn) ->
txn.dontPersist = true
origCommit.apply(model, arguments)

View file

@ -179,8 +179,9 @@ cron = (resetDom_cb) ->
today = +new Date
daysPassed = helpers.daysBetween(today, user.get('lastCron'))
if daysPassed > 0
user.set 'lastCron', today
batch = new schema.BatchUpdate(model)
batch.startTransaction()
batch.set 'lastCron', today
userObj = batch.userObj
hpBefore = userObj.stats.hp #we'll use this later so we can animate hp loss
# Tally each task