diff options
author | mat <github@matdoes.dev> | 2021-05-27 20:04:00 -0500 |
---|---|---|
committer | mat <github@matdoes.dev> | 2021-05-27 20:04:00 -0500 |
commit | f065fd2dd0fa38870727069e0ff2382c21cfe080 (patch) | |
tree | aa5141651b1608d47f60b8e87f1118e5c06614f4 /src/database.ts | |
parent | 735e506b8da1c8461380a409492032752d3f9edf (diff) | |
download | skyblock-api-f065fd2dd0fa38870727069e0ff2382c21cfe080.tar.gz skyblock-api-f065fd2dd0fa38870727069e0ff2382c21cfe080.tar.bz2 skyblock-api-f065fd2dd0fa38870727069e0ff2382c21cfe080.zip |
make leaderboards send less requests
Diffstat (limited to 'src/database.ts')
-rw-r--r-- | src/database.ts | 8 |
1 files changed, 6 insertions, 2 deletions
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<void> { async function fetchAllLeaderboards(fast?: boolean): Promise<void> { 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) } |