fix completedWith.toLowerCase bug

This commit is contained in:
Berkeley Martinez
2015-08-03 16:35:22 -07:00
parent 4c94bf7fcd
commit a920e16cb9

View File

@ -372,7 +372,7 @@ module.exports = function(app) {
function completedZiplineOrBasejump(req, res, next) {
var completedWith = req.body.challengeInfo.completedWith || false;
var completedWith = req.body.challengeInfo.completedWith || '';
var completedDate = Math.round(+new Date());
var challengeId = req.body.challengeInfo.challengeId;
var solutionLink = req.body.challengeInfo.publicURL;
@ -423,17 +423,17 @@ module.exports = function(app) {
pairedWith: pairedWith
};
})
.doOnNext(function(dats) {
.doOnNext(function({ user, pairedWith }) {
updateUserProgress(
dats.user,
user,
challengeId,
dats.pairedWith ?
assign({ completedWith: dats.pairedWith.id }, challengeData) :
pairedWith ?
assign({ completedWith: pairedWith.id }, challengeData) :
challengeData
);
})
.flatMap(function(dats) {
return Rx.Observable.from([dats.user, dats.pairedWith]);
.flatMap(function({ user, pairedWith }) {
return Rx.Observable.from([user, pairedWith]);
})
// save users
.flatMap(function(user) {