This commit is contained in:
Valentin Kaelin 2021-09-28 11:15:35 +02:00
commit 398ecfe7ae
3 changed files with 11 additions and 1 deletions

View file

@ -42,12 +42,16 @@ export default class SummonersController {
finalJSON.seasons = [getCurrentSeason()] finalJSON.seasons = [getCurrentSeason()]
// CURRENT GAME // CURRENT GAME
console.time('playing')
const currentGame = await Jax.Spectator.summonerID(account.id, region) const currentGame = await Jax.Spectator.summonerID(account.id, region)
finalJSON.playing = !!currentGame finalJSON.playing = !!currentGame
finalJSON.current = currentGame finalJSON.current = currentGame
console.timeEnd('playing')
// RANKED STATS // RANKED STATS
console.time('ranked')
finalJSON.ranked = await SummonerService.getRanked(account.id, region) finalJSON.ranked = await SummonerService.getRanked(account.id, region)
console.timeEnd('ranked')
// RECENT ACTIVITY // RECENT ACTIVITY
finalJSON.recentActivity = await StatsService.getRecentActivity(account.puuid) finalJSON.recentActivity = await StatsService.getRecentActivity(account.puuid)

View file

@ -21,6 +21,7 @@ class MatchService {
let alreadyIn = false let alreadyIn = false
let index = 0 let index = 0
do { do {
console.log('--> CALL TO RIOT MATCHLIST')
const newMatchList = await Jax.Matchlist.puuid(account.puuid, region, index) const newMatchList = await Jax.Matchlist.puuid(account.puuid, region, index)
// Error while fetching Riot API // Error while fetching Riot API
if (!newMatchList) { if (!newMatchList) {
@ -49,6 +50,7 @@ class MatchService {
const currentMatchList = await summonerDB.related('matchList').query().orderBy('matchId', 'asc') const currentMatchList = await summonerDB.related('matchList').query().orderBy('matchId', 'asc')
const currentMatchListIds = currentMatchList.map((m) => m.matchId) const currentMatchListIds = currentMatchList.map((m) => m.matchId)
console.time('RiotMatchList')
const newMatchList = await this._fetchMatchListUntil( const newMatchList = await this._fetchMatchListUntil(
account, account,
region, region,
@ -56,6 +58,7 @@ class MatchService {
return currentMatchListIds.some((id) => id === newMatchList[newMatchList.length - 1]) return currentMatchListIds.some((id) => id === newMatchList[newMatchList.length - 1])
} }
) )
console.timeEnd('RiotMatchList')
const matchListToSave: MatchlistDto = [] const matchListToSave: MatchlistDto = []
for (const matchId of newMatchList.reverse()) { for (const matchId of newMatchList.reverse()) {

View file

@ -5,7 +5,10 @@ import BasicMatchSerializer from 'App/Serializers/BasicMatchSerializer'
class StatsService { class StatsService {
public async getRecentActivity(puuid: string) { public async getRecentActivity(puuid: string) {
return MatchRepository.recentActivity(puuid) console.time('RecentActivity')
const recentActivity = await MatchRepository.recentActivity(puuid)
console.timeEnd('RecentActivity')
return recentActivity
} }
public async getSummonerStats(puuid: string, season?: number) { public async getSummonerStats(puuid: string, season?: number) {
console.time('GLOBAL') console.time('GLOBAL')