aboutsummaryrefslogtreecommitdiff
path: root/build/database.js
diff options
context:
space:
mode:
authormat <github@matdoes.dev>2021-05-27 20:04:00 -0500
committermat <github@matdoes.dev>2021-05-27 20:04:00 -0500
commitf065fd2dd0fa38870727069e0ff2382c21cfe080 (patch)
treeaa5141651b1608d47f60b8e87f1118e5c06614f4 /build/database.js
parent735e506b8da1c8461380a409492032752d3f9edf (diff)
downloadskyblock-api-f065fd2dd0fa38870727069e0ff2382c21cfe080.tar.gz
skyblock-api-f065fd2dd0fa38870727069e0ff2382c21cfe080.tar.bz2
skyblock-api-f065fd2dd0fa38870727069e0ff2382c21cfe080.zip
make leaderboards send less requests
Diffstat (limited to 'build/database.js')
-rw-r--r--build/database.js8
1 files changed, 6 insertions, 2 deletions
diff --git a/build/database.js b/build/database.js
index d228057..55c86eb 100644
--- a/build/database.js
+++ b/build/database.js
@@ -504,15 +504,19 @@ async function removeBadMemberLeaderboardAttributes() {
/** Fetch all the leaderboards, used for caching. Don't call this often! */
async function fetchAllLeaderboards(fast) {
const leaderboards = await fetchAllMemberLeaderboardAttributes();
+ if (_1.debug)
+ console.debug('Caching raw leaderboards!');
+ for (const leaderboard of util_1.shuffle(leaderboards))
+ await fetchMemberLeaderboardRaw(leaderboard);
// shuffle so if the application is restarting many times itll still be useful
if (_1.debug)
console.debug('Caching leaderboards!');
for (const leaderboard of util_1.shuffle(leaderboards)) {
if (!fast)
// wait 2 seconds so it doesnt use as much ram
- await util_1.sleep(2 * 1000);
+ await util_1.sleep(10 * 1000);
else
- await util_1.sleep(500);
+ await util_1.sleep(2 * 1000);
await fetchMemberLeaderboard(leaderboard);
}
if (_1.debug)