From 388c14e5acde214be2c46818a6ed90230f5b779f Mon Sep 17 00:00:00 2001 From: Valentin Kaelin Date: Mon, 25 Sep 2023 01:20:27 +0200 Subject: [PATCH] feat: get more recent summoner name in mates query --- server/app/Repositories/MatchRepository.ts | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/server/app/Repositories/MatchRepository.ts b/server/app/Repositories/MatchRepository.ts index 1e604d9..18d22aa 100644 --- a/server/app/Repositories/MatchRepository.ts +++ b/server/app/Repositories/MatchRepository.ts @@ -224,14 +224,26 @@ class MatchRepository { public async mates(filters: SelectFilters) { const query = ` SELECT - (array_agg(mates.summoner_name ORDER BY mates.match_id DESC))[1] as name, + ( + SELECT + summoner_name + FROM + match_players + WHERE + summoner_puuid = mates.summoner_puuid + ORDER BY + match_id DESC + LIMIT + 1 + ) AS name, COUNT(match_players.id) as count, SUM(match_players.win) as wins, SUM(match_players.loss) as losses FROM match_players ${this.JOIN_MATCHES} - INNER JOIN match_players as mates ON match_players.match_id = mates.match_id AND match_players.team = mates.team + INNER JOIN + match_players as mates ON match_players.match_id = mates.match_id AND match_players.team = mates.team WHERE ${this.globalFilters(filters)} GROUP BY