diff --git a/src/app/misc.coffee b/src/app/misc.coffee index f12571bbb7..735addb804 100644 --- a/src/app/misc.coffee +++ b/src/app/misc.coffee @@ -26,7 +26,7 @@ module.exports.score = (model, taskId, direction, allowUndo=false) -> model.set '_undo', {stats:_.cloneDeep(uObj.stats), task:tObjBefore, timeoutId: timeoutId} paths = {} - delta = algos.score(uObj, tObj, direction, {paths:paths}) + delta = algos.score(uObj, tObj, direction, {paths}) _.each paths, (v,k) -> user.set(k,helpers.dotGet(k, uObj)); true model.set('_streakBonus', uObj._tmp.streakBonus) if uObj._tmp?.streakBonus if uObj._tmp?.drop and $? diff --git a/src/server/api.coffee b/src/server/api.coffee index 8d8e329444..45b0250b17 100644 --- a/src/server/api.coffee +++ b/src/server/api.coffee @@ -3,7 +3,7 @@ router = new express.Router() _ = require 'lodash' algos = require 'habitrpg-shared/script/algos' -{ tnl } = algos +helpers = require 'habitrpg-shared/script/helpers' validator = require 'derby-auth/node_modules/validator' check = validator.check sanitize = validator.sanitize @@ -52,7 +52,7 @@ auth = (req, res, next) -> router.get '/user', auth, (req, res) -> user = req.userObj - user.stats.toNextLevel = tnl user.stats.lvl + user.stats.toNextLevel = algos.tnl user.stats.lvl user.stats.maxHealth = 50 delete user.apiToken diff --git a/test/api.mocha.coffee b/test/api.mocha.coffee index 3542a3e0fb..844da7b735 100644 --- a/test/api.mocha.coffee +++ b/test/api.mocha.coffee @@ -373,13 +373,13 @@ describe 'API', -> expect(res.statusCode).to.be 201 tasks = res.body.tasks - expect(_.first(tasks,{id:habitId})).to.eql {id: habitId,text: 'hello2',notes: 'note2'} + expect(_.find(tasks,{id:habitId})).to.eql {id: habitId,text: 'hello2',notes: 'note2'} - foundNewTask = _.findWhere(tasks,{text:'new task2'}) + foundNewTask = _.find(tasks,{text:'new task2'}) expect(foundNewTask.text).to.be 'new task2' expect(foundNewTask.notes).to.be 'notes2' - found = _.findWhere(res.body.tasks, {id:dailyId}) + found = _.find(res.body.tasks, {id:dailyId}) expect(found).to.not.be.ok() query.fetch (err, user) ->