fix: check summoner friends with account_id instead of name

This commit is contained in:
Valentin Kaelin 2020-01-08 21:16:21 +01:00
parent cbd66f1a3b
commit 304ed03ace
4 changed files with 22 additions and 11 deletions

View file

@ -23,9 +23,9 @@
class="flex justify-between items-center"
>
<router-link
:to="{ name: 'summoner', params: { region: $route.params.region, name: mate._id }}"
:to="{ name: 'summoner', params: { region: $route.params.region, name: mate.name }}"
class="w-2/4 hover:text-teal-200"
>{{ mate._id }}</router-link>
>{{ mate.name }}</router-link>
<div class="w-1/4">{{ mate.wins }} / {{ mate.losses }}</div>
<div class="w-1/4">
<Dropdown>

View file

@ -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)
}
}

View file

@ -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],

View file

@ -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,