Add methods to get challengeMap

Update boot/challenge.js to use new methods
Update boot/user.js to use new methods
This commit is contained in:
Berkeley Martinez
2016-04-06 21:08:19 -07:00
parent 7737bfedc1
commit 1308d312a4
5 changed files with 132 additions and 97 deletions

View File

@ -441,4 +441,28 @@ module.exports = function(User) {
}
return this.constructor.update$({ id }, updateData, updateOptions);
};
User.prototype.getPoints$ = function getPoints$() {
const id = this.getId();
const filter = {
where: { id },
fields: { progressTimestamps: true }
};
return this.constructor.findOne$(filter)
.map(user => {
this.progressTimestamps = user.progressTimestamps;
return user.progressTimestamps;
});
};
User.prototype.getChallengeMap$ = function getChallengeMap$() {
const id = this.getId();
const filter = {
where: { id },
fields: { challengeMap: true }
};
return this.constructor.findOne$(filter)
.map(user => {
this.challengeMap = user.challengeMap;
return user.challengeMap;
});
};
};