Fix challenge sorting

Closes #7543
Closes #7507
This commit is contained in:
Shervin Sarain
2016-05-30 19:04:13 +02:00
committed by Blade Barringer
parent a11a999839
commit de21487038
3 changed files with 244 additions and 110 deletions
@@ -201,7 +201,7 @@ api.leaveChallenge = {
* @apiName GetUserChallenges
* @apiGroup Challenge
*
* @apiSuccess {Array} data An array of challenges
* @apiSuccess {Array} data An array of challenges sorted with official challenges first, followed by the challenges in order from newest to oldest
*/
api.getUserChallenges = {
method: 'GET',
@@ -218,7 +218,7 @@ api.getUserChallenges = {
],
_id: {$ne: '95533e05-1ff9-4e46-970b-d77219f199e9'}, // remove the Spread the Word Challenge for now, will revisit when we fix the closing-challenge bug TODO revisit
})
.sort('-official -timestamp')
.sort('-official -createdAt')
// see below why we're not using populate
// .populate('group', basicGroupFields)
// .populate('leader', nameFields)
@@ -249,7 +249,7 @@ api.getUserChallenges = {
*
* @apiParam {groupId} groupId The group _id
*
* @apiSuccess {Array} data An array of challenges
* @apiSuccess {Array} data An array of challenges sorted with official challenges first, followed by the challenges in order from newest to oldest
*/
api.getGroupChallenges = {
method: 'GET',
@@ -268,7 +268,7 @@ api.getGroupChallenges = {
if (!group) throw new NotFound(res.t('groupNotFound'));
let challenges = await Challenge.find({group: groupId})
.sort('-official -timestamp')
.sort('-official -createdAt')
// .populate('leader', nameFields) // Only populate the leader as the group is implicit
.exec();