aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormat <github@matdoes.dev>2021-05-30 22:45:14 -0500
committermat <github@matdoes.dev>2021-05-30 22:45:14 -0500
commit5541e5d3b99cbf5ed0436e89f0c4ccabf64e400a (patch)
treeef132c1c23a84f23ff0e5c2f72a8fca566bc0825 /src
parenta61e50c845e686c9513afca715d35088472c2941 (diff)
downloadskyblock-api-5541e5d3b99cbf5ed0436e89f0c4ccabf64e400a.tar.gz
skyblock-api-5541e5d3b99cbf5ed0436e89f0c4ccabf64e400a.tar.bz2
skyblock-api-5541e5d3b99cbf5ed0436e89f0c4ccabf64e400a.zip
re-add the pre-cache for leaderboard users
Diffstat (limited to 'src')
-rw-r--r--src/database.ts7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/database.ts b/src/database.ts
index 6dc8ed4..3cad5b5 100644
--- a/src/database.ts
+++ b/src/database.ts
@@ -688,16 +688,15 @@ async function fetchAllLeaderboards(fast?: boolean): Promise<void> {
for (const leaderboard of shuffle(leaderboards))
await fetchMemberLeaderboardRaw(leaderboard)
finishedCachingRawLeaderboards = true
- return
// 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(10 * 1000)
- else
await sleep(2 * 1000)
+ else
+ await sleep(500)
await fetchMemberLeaderboard(leaderboard)
}
@@ -743,7 +742,7 @@ if (!globalThis.isTest) {
// when it connects, cache the leaderboards and remove bad members
removeBadMemberLeaderboardAttributes()
// cache leaderboards on startup so its faster later on
- fetchAllLeaderboards(false)
+ fetchAllLeaderboards(true)
// cache leaderboard players again every 4 hours
setInterval(fetchAllLeaderboards, 4 * 60 * 60 * 1000)
})