From 4ab2f45ff3767c3deb4b79cfc343f492941847b0 Mon Sep 17 00:00:00 2001 From: mat Date: Fri, 28 May 2021 22:11:24 -0500 Subject: add more useful stuff to index --- src/database.ts | 5 +++++ src/hypixelCached.ts | 1 - src/index.ts | 6 ++++-- 3 files changed, 9 insertions(+), 3 deletions(-) (limited to 'src') 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 { } } +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 { const leaderboards: string[] = await fetchAllMemberLeaderboardAttributes() @@ -666,6 +669,7 @@ async function fetchAllLeaderboards(fast?: boolean): Promise { 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 { 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 }) }) -- cgit