@@ -58,7 +57,7 @@ import LoadingButton from '@/components/Form/LoadingButton.vue'
import Match from '@/components/Match/Match.vue'
import OverviewLoader from '@/components/Summoner/Overview/OverviewLoader.vue'
import SummonerChampions from '@/components/Summoner/Overview/SummonerChampions.vue'
-// import SummonerMates from '@/components/Summoner/Overview/SummonerMates.vue'
+import SummonerMates from '@/components/Summoner/Overview/SummonerMates.vue'
import SummonerStats from '@/components/Summoner/Overview/SummonerStats.vue'
import VueStickySidebar from 'vue-sticky-sidebar'
@@ -69,7 +68,7 @@ export default {
Match,
OverviewLoader,
SummonerChampions,
- // SummonerMates,
+ SummonerMates,
SummonerStats,
VueStickySidebar
},
diff --git a/server-v2/app/Repositories/MatchRepository.ts b/server-v2/app/Repositories/MatchRepository.ts
index 5c3bc40..55fa08b 100644
--- a/server-v2/app/Repositories/MatchRepository.ts
+++ b/server-v2/app/Repositories/MatchRepository.ts
@@ -7,7 +7,7 @@ class MatchRepository {
private readonly JOIN_ALL = `${this.JOIN_MATCHES} ${this.JOIN_TEAMS}`
private readonly GLOBAL_FILTERS = `
- summoner_puuid = :puuid
+ match_players.summoner_puuid = :puuid
AND match_teams.result != 'Remake'
AND matches.gamemode NOT IN (800, 810, 820, 830, 840, 850, 2000, 2010, 2020)
`
@@ -146,6 +146,32 @@ class MatchRepository {
const { rows } = await Database.rawQuery(query, { puuid })
return rows
}
+
+ public async mates(puuid: string) {
+ const query = `
+ SELECT
+ (array_agg(mates.summoner_name ORDER BY mates.match_id DESC))[1] as name,
+ COUNT(match_players.id) as count,
+ COUNT(case when match_teams.result = 'Win' then 1 else null end) as wins,
+ COUNT(case when match_teams.result = 'Fail' then 1 else null end) as losses
+ FROM
+ match_players
+ ${this.JOIN_ALL}
+ INNER JOIN match_players as mates ON match_players.match_id = mates.match_id AND match_players.team = mates.team
+ WHERE
+ ${this.GLOBAL_FILTERS}
+ GROUP BY
+ mates.summoner_puuid
+ ORDER BY
+ count DESC, wins DESC
+ LIMIT
+ 15
+ `
+ const { rows } = await Database.rawQuery(query, { puuid })
+
+ // Remove the Summoner himself + unique game mates
+ return rows.splice(1).filter((row) => row.count > 1)
+ }
}
export default new MatchRepository()
diff --git a/server-v2/app/Services/StatsService.ts b/server-v2/app/Services/StatsService.ts
index 2e58853..8ba4081 100644
--- a/server-v2/app/Services/StatsService.ts
+++ b/server-v2/app/Services/StatsService.ts
@@ -41,17 +41,17 @@ class StatsService {
champ.id = ChampionRoles[champ.id]
}
console.timeEnd('CHAMPION-CLASS')
- // console.time('MATES')
- // const mates = await MatchRepository.mates(puuid, season)
- // console.timeEnd('MATES')
+ console.time('MATES')
+ const mates = await MatchRepository.mates(puuid)
+ console.timeEnd('MATES')
return {
global: globalStats,
league: gamemodeStats,
role: roleStats.sort(sortTeamByRole),
- class: championClassStats,
- // mates,
champion: championStats,
+ class: championClassStats,
+ mates,
}
}
}