mirror of
https://github.com/vkaelin/LeagueStats.git
synced 2026-03-25 12:57:28 +00:00
26 lines
633 B
TypeScript
26 lines
633 B
TypeScript
|
|
import Database from '@ioc:Adonis/Lucid/Database'
|
||
|
|
|
||
|
|
class MatchRepository {
|
||
|
|
public async globalStats(puuid: string, season?: number) {
|
||
|
|
// TODO: add wins/losses
|
||
|
|
return Database.from('match_players')
|
||
|
|
.where('summoner_puuid', puuid)
|
||
|
|
.join('matches', 'match_players.match_id', 'matches.id')
|
||
|
|
.sum({
|
||
|
|
assists: 'assists',
|
||
|
|
deaths: 'deaths',
|
||
|
|
kills: 'kills',
|
||
|
|
minions: 'minions',
|
||
|
|
time: 'matches.game_duration',
|
||
|
|
vision: 'vision_score',
|
||
|
|
})
|
||
|
|
.count({
|
||
|
|
count: 'assists',
|
||
|
|
})
|
||
|
|
.avg('kp')
|
||
|
|
.first()
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
export default new MatchRepository()
|