From a4dd9667ca8a5db2c858a9800a3d5b016b12aab6 Mon Sep 17 00:00:00 2001 From: Berkeley Martinez Date: Wed, 10 Feb 2016 10:05:51 -0800 Subject: [PATCH] Fix typos --- common/models/user.js | 8 +++++--- server/boot/certificate.js | 4 ++-- server/boot/challenge.js | 13 ++++++++----- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/common/models/user.js b/common/models/user.js index cc81e01fa9..6d45beb6c2 100644 --- a/common/models/user.js +++ b/common/models/user.js @@ -430,11 +430,13 @@ module.exports = function(User) { if ( !updateData || typeof updateData !== 'object' || - Object.keys(updateData).length > 0 + !Object.keys(updateData).length ) { return Observable.throw(new Error( - `updateData must be an object with at least on key, - but got ${updateData}`.split('\n').join(' ') + dedent` + updateData must be an object with at least one key, + but got ${updateData} with ${Object.keys(updateData).length} + `.split('\n').join(' ') )); } return this.constructor.update$({ id }, updateData, updateOptions); diff --git a/server/boot/certificate.js b/server/boot/certificate.js index b8e46428f4..e4082e5f74 100644 --- a/server/boot/certificate.js +++ b/server/boot/certificate.js @@ -84,7 +84,7 @@ export default function certificate(app) { function verifyCert(certType, req, res, next) { const { user } = req; - return certTypeIds[certType]() + return certTypeIds[certType] .flatMap(challenge => { const { id, @@ -108,7 +108,7 @@ export default function certificate(app) { } }; - return req.user.udate$(updateData) + return req.user.update$(updateData) // If user has commited to nonprofit, // this will complete his pledge .flatMap( diff --git a/server/boot/challenge.js b/server/boot/challenge.js index 1f7fda0d4d..aade450945 100644 --- a/server/boot/challenge.js +++ b/server/boot/challenge.js @@ -84,6 +84,7 @@ function buildUserUpdate( }; if ( + timezone && timezone !== 'UTC' && (!userTimezone || userTimezone === 'UTC') ) { @@ -538,16 +539,18 @@ module.exports = function(app) { ); const user = req.user; - return user.updateTo$(updateData) - .doOnNext(count => log('%s documents updated', count)) + const points = alreadyCompleted ? + user.progressTimestamps.length : + user.progressTimestamps.length + 1; + return user.update$(updateData) + .doOnNext(({ count }) => log('%s documents updated', count)) .subscribe( - function() { - }, + () => {}, next, function() { if (type === 'json') { return res.json({ - points: user.progressTimestamps.length, + points, alreadyCompleted }); }