mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-27 09:35:39 -05:00
Fix Mongoose 4 update change the right way for completing level achievement calculations
This commit is contained in:
parent
7269dc85d4
commit
2db3145e19
1 changed files with 1 additions and 2 deletions
|
@ -60,11 +60,10 @@ LevelSessionSchema.pre 'save', (next) ->
|
|||
update = $inc: {'stats.gamesCompleted': 1}
|
||||
for concept in level?.concepts ? []
|
||||
update.$inc["stats.concepts.#{concept}"] = 1
|
||||
User.findByIdAndUpdate userID, update, {}, (err, user) ->
|
||||
User.findByIdAndUpdate userID, update, {new: true}, (err, user) ->
|
||||
log.error err if err?
|
||||
oldCopy = user.toObject()
|
||||
oldCopy.stats = _.clone oldCopy.stats
|
||||
oldCopy.stats ?= {gamesCompleted: 0}
|
||||
--oldCopy.stats.gamesCompleted
|
||||
oldCopy.stats.concepts ?= {}
|
||||
for concept in level?.concepts ? []
|
||||
|
|
Loading…
Reference in a new issue