mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-19 15:48:04 +01:00
Merge branch 'develop' into pushNotifications2
This commit is contained in:
@@ -40,7 +40,7 @@ api.list = function(req, res, next) {
|
||||
.select('name leader description group memberCount prize official')
|
||||
.select({members:{$elemMatch:{$in:[user._id]}}})
|
||||
.sort('-official -timestamp')
|
||||
.populate('group', '_id name')
|
||||
.populate('group', '_id name type')
|
||||
.populate('leader', 'profile.name')
|
||||
.exec(cb);
|
||||
}
|
||||
@@ -56,17 +56,23 @@ api.list = function(req, res, next) {
|
||||
|
||||
// GET
|
||||
api.get = function(req, res, next) {
|
||||
var user = res.locals.user;
|
||||
// TODO use mapReduce() or aggregate() here to
|
||||
// 1) Find the sum of users.tasks.values within the challnege (eg, {'profile.name':'tyler', 'sum': 100})
|
||||
// 2) Sort by the sum
|
||||
// 3) Limit 30 (only show the 30 users currently in the lead)
|
||||
Challenge.findById(req.params.cid)
|
||||
.populate('members', 'profile.name _id')
|
||||
.populate('group', '_id name type')
|
||||
.populate('leader', 'profile.name')
|
||||
.exec(function(err, challenge){
|
||||
if(err) return next(err);
|
||||
if (!challenge) return res.json(404, {err: 'Challenge ' + req.params.cid + ' not found'});
|
||||
challenge._isMember = !!(_.find(challenge.members, function(member) {
|
||||
return member._id === user._id;
|
||||
}));
|
||||
res.json(challenge);
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
api.csv = function(req, res, next) {
|
||||
|
||||
Reference in New Issue
Block a user