aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/database.ts5
-rw-r--r--src/hypixelCached.ts1
-rw-r--r--src/index.ts6
3 files changed, 9 insertions, 3 deletions
diff --git a/src/database.ts b/src/database.ts
index b198012..01dec3c 100644
--- a/src/database.ts
+++ b/src/database.ts
@@ -658,6 +658,9 @@ async function removeBadMemberLeaderboardAttributes(): Promise<void> {
}
}
+export let finishedCachingRawLeaderboards = false
+export let finishedCachingAllLeaderboards = false
+
/** Fetch all the leaderboards, used for caching. Don't call this often! */
async function fetchAllLeaderboards(fast?: boolean): Promise<void> {
const leaderboards: string[] = await fetchAllMemberLeaderboardAttributes()
@@ -666,6 +669,7 @@ async function fetchAllLeaderboards(fast?: boolean): Promise<void> {
for (const leaderboard of shuffle(leaderboards))
await fetchMemberLeaderboardRaw(leaderboard)
+ finishedCachingRawLeaderboards = true
// shuffle so if the application is restarting many times itll still be useful
if (debug) console.debug('Caching leaderboards!')
@@ -678,6 +682,7 @@ async function fetchAllLeaderboards(fast?: boolean): Promise<void> {
await fetchMemberLeaderboard(leaderboard)
}
+ finishedCachingAllLeaderboards = true
if (debug) console.debug('Finished caching leaderboards!')
}
diff --git a/src/hypixelCached.ts b/src/hypixelCached.ts
index 8bdd81e..b3b9c87 100644
--- a/src/hypixelCached.ts
+++ b/src/hypixelCached.ts
@@ -10,7 +10,6 @@ import { CleanPlayer } from './cleaners/player'
import { isUuid, undashUuid } from './util'
import { CleanProfile, CleanFullProfile, CleanBasicProfile } from './cleaners/skyblock/profile'
import { debug } from '.'
-import { cachedRawLeaderboards } from './database'
// cache usernames for 4 hours
/** uuid: username */
diff --git a/src/index.ts b/src/index.ts
index 0500df6..952c2aa 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -1,4 +1,4 @@
-import { createSession, fetchAccount, fetchAccountFromDiscord, fetchAllLeaderboardsCategorized, fetchLeaderboard, fetchMemberLeaderboardSpots, fetchSession, updateAccount } from './database'
+import { createSession, fetchAccount, fetchAccountFromDiscord, fetchAllLeaderboardsCategorized, fetchLeaderboard, fetchMemberLeaderboardSpots, fetchSession, finishedCachingAllLeaderboards, finishedCachingRawLeaderboards, updateAccount } from './database'
import { fetchMemberProfile, fetchUser } from './hypixel'
import rateLimit from 'express-rate-limit'
import * as constants from './constants'
@@ -35,7 +35,9 @@ app.get('/', async(req, res) => {
const currentTime = Date.now()
res.json({
ok: true,
- uptimeHours: (currentTime - startTime) / 1000 / 60 / 60
+ uptimeHours: (currentTime - startTime) / 1000 / 60 / 60,
+ finishedCachingRawLeaderboards,
+ finishedCachingAllLeaderboards
})
})