fix: sorted some queries results (champions/mates)

This commit is contained in:
Valentin Kaelin 2020-03-22 17:52:35 +01:00
parent 788f733c96
commit 897055b189

View file

@ -74,7 +74,7 @@ class MatchRepository {
assists: { $sum: '$stats.assists' }, assists: { $sum: '$stats.assists' },
} }
const finalSteps = [ const finalSteps = [
{ $sort: { 'count': -1 } }, { $sort: { 'count': -1, 'champion.name': 1 } },
{ $limit: limit } { $limit: limit }
] ]
return this._aggregate(puuid, {}, [], '$champion.id', groupParams, finalSteps) return this._aggregate(puuid, {}, [], '$champion.id', groupParams, finalSteps)
@ -117,7 +117,7 @@ class MatchRepository {
kp: { $avg: '$stats.kp' }, kp: { $avg: '$stats.kp' },
} }
const finalSteps = [ const finalSteps = [
{ $sort: { 'count': -1 } } { $sort: { 'count': -1, 'champion.name': 1 } }
] ]
return this._aggregate(puuid, matchParams, [], '$champion.id', groupParams, finalSteps) return this._aggregate(puuid, matchParams, [], '$champion.id', groupParams, finalSteps)
} }
@ -263,6 +263,7 @@ class MatchRepository {
*/ */
mates(puuid) { mates(puuid) {
const intermediateSteps = [ const intermediateSteps = [
{ $sort: { 'gameId': -1 } },
{ $unwind: '$allyTeam' }, { $unwind: '$allyTeam' },
] ]
const groupParams = { const groupParams = {
@ -282,7 +283,7 @@ class MatchRepository {
'count': { $gte: 2 } 'count': { $gte: 2 }
}, },
}, },
{ $sort: { 'count': -1 } }, { $sort: { 'count': -1, 'name': 1 } },
{ $limit: 15 }, { $limit: 15 },
] ]
return this._aggregate(puuid, {}, intermediateSteps, '$allyTeam.account_id', groupParams, finalSteps) return this._aggregate(puuid, {}, intermediateSteps, '$allyTeam.account_id', groupParams, finalSteps)