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()]
// CURRENT GAME
console.time('playing')
const currentGame = await Jax.Spectator.summonerID(account.id, region)
finalJSON.playing = !!currentGame
finalJSON.current = currentGame
console.timeEnd('playing')
// RANKED STATS
console.time('ranked')
finalJSON.ranked = await SummonerService.getRanked(account.id, region)
console.timeEnd('ranked')
// RECENT ACTIVITY
console.time('RecentActivity')
finalJSON.recentActivity = await StatsService.getRecentActivity(account.puuid)
console.timeEnd('RecentActivity')
} catch (e) {
console.log(e)
console.timeEnd('BASIC_REQUEST')

View file

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

View file

@ -5,7 +5,10 @@ import BasicMatchSerializer from 'App/Serializers/BasicMatchSerializer'
class StatsService {
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) {
console.time('GLOBAL')