diff --git a/client/src/components/Summoner/Overview/SummonerMates.vue b/client/src/components/Summoner/Overview/SummonerMates.vue index 2662d1e..092ad3f 100644 --- a/client/src/components/Summoner/Overview/SummonerMates.vue +++ b/client/src/components/Summoner/Overview/SummonerMates.vue @@ -23,9 +23,9 @@ class="flex justify-between items-center" > {{ mate._id }} + >{{ mate.name }}
{{ mate.wins }} / {{ mate.losses }}
diff --git a/server/app/Repositories/MatchRepository.js b/server/app/Repositories/MatchRepository.js index cc80ae6..c911ffa 100644 --- a/server/app/Repositories/MatchRepository.js +++ b/server/app/Repositories/MatchRepository.js @@ -156,23 +156,32 @@ class MatchRepository { /** * Get Summoner's mates list * @param puuid of the summoner - * @param summonerName of the summoner */ - mates(puuid, summonerName) { + mates(puuid) { const intermediateSteps = [ { $unwind: "$allyTeam" }, ] + const groupParams = { + account_id: { $first: "$account_id" }, + name: { $first: "$allyTeam.name" }, + mateId: { $first: "$allyTeam.account_id" }, + } const finalSteps = [ { - $match: { - _id: { $not: { $eq: summonerName } }, - 'count': { $gte: 2 } + "$addFields": { + "idEq": { "$eq": ["$mateId", "$account_id"] } } }, + { + $match: { + 'idEq': false, + 'count': { $gte: 2 } + }, + }, { $sort: { 'count': -1 } }, { $limit: 15 }, ] - return this._aggregate(puuid, {}, intermediateSteps, '$allyTeam.name', {}, finalSteps) + return this._aggregate(puuid, {}, intermediateSteps, '$allyTeam.account_id', groupParams, finalSteps) } } diff --git a/server/app/Services/StatsService.js b/server/app/Services/StatsService.js index 9504a77..c552e6b 100644 --- a/server/app/Services/StatsService.js +++ b/server/app/Services/StatsService.js @@ -26,7 +26,7 @@ class StatsService { } const championStats = await this.matchRepository.championStats(account.puuid, 5) const championClassStats = await this.matchRepository.championClassStats(account.puuid) - const mates = await this.matchRepository.mates(account.puuid, account.name) + const mates = await this.matchRepository.mates(account.puuid) return { global: globalStats[0], diff --git a/server/app/Transformers/BasicMatchTransformer.js b/server/app/Transformers/BasicMatchTransformer.js index 88c04ce..71175a7 100644 --- a/server/app/Transformers/BasicMatchTransformer.js +++ b/server/app/Transformers/BasicMatchTransformer.js @@ -34,8 +34,8 @@ class BasicMatchTransformer extends MatchTransformer { // Global data about the match const globalInfos = super.getGameInfos(match) - const participantId = match.participantIdentities.find((p) => p.player.currentAccountId === account.accountId).participantId - const player = match.participants[participantId - 1] + const identity = match.participantIdentities.find((p) => p.player.currentAccountId === account.accountId) + const player = match.participants[identity.participantId - 1] let win = match.teams.find((t) => t.teamId === player.teamId).win @@ -53,6 +53,7 @@ class BasicMatchTransformer extends MatchTransformer { for (let summoner of match.participantIdentities) { const allData = match.participants[summoner.participantId - 1] const playerInfos = { + account_id: summoner.player.currentAccountId, name: summoner.player.summonerName, role: super.getRoleName(allData.timeline), champion: super.getChampion(allData.championId) @@ -68,6 +69,7 @@ class BasicMatchTransformer extends MatchTransformer { enemyTeam.sort(this.sortTeamByRole) return { + account_id: identity.player.currentAccountId, summoner_puuid: account.puuid, gameId: match.gameId, result: win,