mirror of
https://github.com/vkaelin/LeagueStats.git
synced 2026-03-25 12:57:28 +00:00
feat: add summoner friends back
This commit is contained in:
parent
73e40820bd
commit
1f5afc3f54
4 changed files with 36 additions and 11 deletions
|
|
@ -19,7 +19,7 @@
|
|||
<ul class="mt-1 text-gray-100">
|
||||
<li
|
||||
v-for="mate in mates.slice(0, maxMates)"
|
||||
:key="mate._id"
|
||||
:key="mate.name"
|
||||
class="flex items-center justify-between"
|
||||
>
|
||||
<router-link
|
||||
|
|
|
|||
|
|
@ -12,8 +12,7 @@
|
|||
>
|
||||
<SummonerChampions />
|
||||
<SummonerStats />
|
||||
<!-- TODO: add it back when implemented -->
|
||||
<!-- <SummonerMates /> -->
|
||||
<SummonerMates />
|
||||
</VueStickySidebar>
|
||||
<div class="w-9/12">
|
||||
<div v-if="current && current.participants" class="mb-4">
|
||||
|
|
@ -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
|
||||
},
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue