mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-08-03 08:21:07 +00:00
fix(challenges): temporarily remove $elemMatch on challenge/user/progress, see #2947
This commit is contained in:
parent
f659206042
commit
e76e545e6a
1 changed files with 10 additions and 2 deletions
|
|
@ -105,12 +105,20 @@ api.csv = function(req, res, next) {
|
|||
|
||||
api.getMember = function(req, res, next) {
|
||||
var cid = req.params.cid, uid = req.params.uid;
|
||||
var elemMatch = {$elemMatch:{'challenge.id':cid}};
|
||||
User.findById(uid)
|
||||
.select({'profile.name':1, habits:elemMatch, dailys:elemMatch, todos:elemMatch, rewards:elemMatch})
|
||||
.select('profile.name habits dailys todos rewards')
|
||||
.exec(function(err, member){
|
||||
if(err) return next(err);
|
||||
if (!member) return res.json(404, {err: 'Member '+uid+' for challenge '+cid+' not found'});
|
||||
|
||||
// Prune un-related tasks. See http://goo.gl/9fnwei
|
||||
// See http://stackoverflow.com/a/18546277/362790 for fix
|
||||
_.each(['habits','dailys','todos', 'rewards'], function(type){
|
||||
member[type] = _.filter(member[type], function(task){
|
||||
return task.challenge && task.challenge.id && task.challenge.id == cid;
|
||||
});
|
||||
});
|
||||
|
||||
res.json(member);
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue