feat: add some console.time to check what's taking time sometimes

This commit is contained in:
Kalane 2021-09-24 22:25:28 +02:00
parent f343992ee6
commit 6c7faa40a9
3 changed files with 13 additions and 1 deletions

View file

@ -42,15 +42,21 @@ 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
console.time('RecentActivity')
finalJSON.recentActivity = await StatsService.getRecentActivity(account.puuid) finalJSON.recentActivity = await StatsService.getRecentActivity(account.puuid)
console.timeEnd('RecentActivity')
} catch (e) { } catch (e) {
console.log(e) console.log(e)
console.timeEnd('BASIC_REQUEST') console.timeEnd('BASIC_REQUEST')

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')