Last active
February 19, 2016 02:58
-
-
Save BerkeleyTrue/4eaba6684a07453129b6 to your computer and use it in GitHub Desktop.
Revisions
-
Berkeley Martinez revised this gist
Feb 16, 2016 . 1 changed file with 0 additions and 17 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,17 +0,0 @@ -
Berkeley Martinez renamed this gist
Feb 16, 2016 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
Berkeley Martinez created this gist
Feb 16, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,17 @@ function completedChallenge(req, res, next) { // build user update data, no longer mutates user object const { updateData, alreadyCompleted, points } = buildUpdateData(req); // calls an update data using user instance id and sends only updateData return user.update$(updateData) .subscribe( count => log('%s documents updated', count), next, function() { return res.json({ points, alreadyCompleted }); } ); } } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,17 @@ function completedChallenge(req, res, next) { const { user, body } = req; // mutates user object const { alreadyCompleted } = updateUserProgress(user, body); / sends entire user object to database return saveUser(req.user) .subscribe( () => {}, next, function() { return res.json({ points: user.progressTimestamps.length, alreadyCompleted }); } ); }