From 897055b189a6c08072c6a9f4757a56a5546e6e2b Mon Sep 17 00:00:00 2001 From: Valentin Kaelin Date: Sun, 22 Mar 2020 17:52:35 +0100 Subject: [PATCH] fix: sorted some queries results (champions/mates) --- server/app/Repositories/MatchRepository.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/server/app/Repositories/MatchRepository.js b/server/app/Repositories/MatchRepository.js index 449a442..5a590de 100644 --- a/server/app/Repositories/MatchRepository.js +++ b/server/app/Repositories/MatchRepository.js @@ -74,7 +74,7 @@ class MatchRepository { assists: { $sum: '$stats.assists' }, } const finalSteps = [ - { $sort: { 'count': -1 } }, + { $sort: { 'count': -1, 'champion.name': 1 } }, { $limit: limit } ] return this._aggregate(puuid, {}, [], '$champion.id', groupParams, finalSteps) @@ -117,7 +117,7 @@ class MatchRepository { kp: { $avg: '$stats.kp' }, } const finalSteps = [ - { $sort: { 'count': -1 } } + { $sort: { 'count': -1, 'champion.name': 1 } } ] return this._aggregate(puuid, matchParams, [], '$champion.id', groupParams, finalSteps) } @@ -263,6 +263,7 @@ class MatchRepository { */ mates(puuid) { const intermediateSteps = [ + { $sort: { 'gameId': -1 } }, { $unwind: '$allyTeam' }, ] const groupParams = { @@ -282,7 +283,7 @@ class MatchRepository { 'count': { $gte: 2 } }, }, - { $sort: { 'count': -1 } }, + { $sort: { 'count': -1, 'name': 1 } }, { $limit: 15 }, ] return this._aggregate(puuid, {}, intermediateSteps, '$allyTeam.account_id', groupParams, finalSteps)