diff options
-rw-r--r-- | build/database.js | 6 | ||||
-rw-r--r-- | build/index.js | 4 | ||||
-rw-r--r-- | src/database.ts | 5 | ||||
-rw-r--r-- | src/hypixelCached.ts | 1 | ||||
-rw-r--r-- | src/index.ts | 6 |
5 files changed, 17 insertions, 5 deletions
diff --git a/build/database.js b/build/database.js index e4d7a9b..8e3beb9 100644 --- a/build/database.js +++ b/build/database.js @@ -25,7 +25,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); -exports.updateAccount = exports.fetchAccountFromDiscord = exports.fetchAccount = exports.fetchSession = exports.createSession = exports.queueUpdateDatabaseProfile = exports.queueUpdateDatabaseMember = exports.updateDatabaseProfile = exports.updateDatabaseMember = exports.fetchMemberLeaderboardSpots = exports.fetchLeaderboard = exports.fetchProfileLeaderboard = exports.fetchMemberLeaderboard = exports.fetchAllMemberLeaderboardAttributes = exports.fetchSlayerLeaderboards = exports.fetchAllLeaderboardsCategorized = exports.cachedRawLeaderboards = void 0; +exports.updateAccount = exports.fetchAccountFromDiscord = exports.fetchAccount = exports.fetchSession = exports.createSession = exports.finishedCachingAllLeaderboards = exports.finishedCachingRawLeaderboards = exports.queueUpdateDatabaseProfile = exports.queueUpdateDatabaseMember = exports.updateDatabaseProfile = exports.updateDatabaseMember = exports.fetchMemberLeaderboardSpots = exports.fetchLeaderboard = exports.fetchProfileLeaderboard = exports.fetchMemberLeaderboard = exports.fetchAllMemberLeaderboardAttributes = exports.fetchSlayerLeaderboards = exports.fetchAllLeaderboardsCategorized = exports.cachedRawLeaderboards = void 0; const stats_1 = require("./cleaners/skyblock/stats"); const slayers_1 = require("./cleaners/skyblock/slayers"); const mongodb_1 = require("mongodb"); @@ -523,6 +523,8 @@ async function removeBadMemberLeaderboardAttributes() { } } } +exports.finishedCachingRawLeaderboards = false; +exports.finishedCachingAllLeaderboards = false; /** Fetch all the leaderboards, used for caching. Don't call this often! */ async function fetchAllLeaderboards(fast) { const leaderboards = await fetchAllMemberLeaderboardAttributes(); @@ -530,6 +532,7 @@ async function fetchAllLeaderboards(fast) { console.debug('Caching raw leaderboards!'); for (const leaderboard of util_1.shuffle(leaderboards)) await fetchMemberLeaderboardRaw(leaderboard); + exports.finishedCachingRawLeaderboards = true; // shuffle so if the application is restarting many times itll still be useful if (_1.debug) console.debug('Caching leaderboards!'); @@ -541,6 +544,7 @@ async function fetchAllLeaderboards(fast) { await util_1.sleep(2 * 1000); await fetchMemberLeaderboard(leaderboard); } + exports.finishedCachingAllLeaderboards = true; if (_1.debug) console.debug('Finished caching leaderboards!'); } diff --git a/build/index.js b/build/index.js index e6ecf13..4644fed 100644 --- a/build/index.js +++ b/build/index.js @@ -55,7 +55,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: database_1.finishedCachingRawLeaderboards, + finishedCachingAllLeaderboards: database_1.finishedCachingAllLeaderboards }); }); app.get('/player/:user', async (req, res) => { 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 }) }) |