From 6c7faa40a9979ba1ff4b653a768a93a92ed56c07 Mon Sep 17 00:00:00 2001 From: Kalane Date: Fri, 24 Sep 2021 22:25:28 +0200 Subject: [PATCH] feat: add some console.time to check what's taking time sometimes --- server/app/Controllers/Http/SummonersController.ts | 6 ++++++ server/app/Services/MatchService.ts | 3 +++ server/app/Services/StatsService.ts | 5 ++++- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/server/app/Controllers/Http/SummonersController.ts b/server/app/Controllers/Http/SummonersController.ts index 5fdb6dc..0bbfc4f 100644 --- a/server/app/Controllers/Http/SummonersController.ts +++ b/server/app/Controllers/Http/SummonersController.ts @@ -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') diff --git a/server/app/Services/MatchService.ts b/server/app/Services/MatchService.ts index 670a12d..4173f78 100644 --- a/server/app/Services/MatchService.ts +++ b/server/app/Services/MatchService.ts @@ -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()) { diff --git a/server/app/Services/StatsService.ts b/server/app/Services/StatsService.ts index 36600ac..43b271f 100644 --- a/server/app/Services/StatsService.ts +++ b/server/app/Services/StatsService.ts @@ -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')