From f065fd2dd0fa38870727069e0ff2382c21cfe080 Mon Sep 17 00:00:00 2001 From: mat Date: Thu, 27 May 2021 20:04:00 -0500 Subject: make leaderboards send less requests --- src/database.ts | 8 ++++++-- src/hypixelApi.ts | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/database.ts b/src/database.ts index 5801f58..7129d2b 100644 --- a/src/database.ts +++ b/src/database.ts @@ -636,14 +636,18 @@ async function removeBadMemberLeaderboardAttributes(): Promise { async function fetchAllLeaderboards(fast?: boolean): Promise { const leaderboards: string[] = await fetchAllMemberLeaderboardAttributes() + if (debug) console.debug('Caching raw leaderboards!') + for (const leaderboard of shuffle(leaderboards)) + await fetchMemberLeaderboardRaw(leaderboard) + // shuffle so if the application is restarting many times itll still be useful if (debug) console.debug('Caching leaderboards!') for (const leaderboard of shuffle(leaderboards)) { if (!fast) // wait 2 seconds so it doesnt use as much ram - await sleep(2 * 1000) + await sleep(10 * 1000) else - await sleep(500) + await sleep(2 * 1000) await fetchMemberLeaderboard(leaderboard) } diff --git a/src/hypixelApi.ts b/src/hypixelApi.ts index 72af1af..4807b2b 100644 --- a/src/hypixelApi.ts +++ b/src/hypixelApi.ts @@ -140,6 +140,7 @@ export async function sendApiRequest({ path, key, args }): Promise httpsAgent } -- cgit