diff options
-rw-r--r-- | build/database.js | 10 | ||||
-rw-r--r-- | build/index.js | 9 | ||||
-rw-r--r-- | src/database.ts | 4 | ||||
-rw-r--r-- | src/index.ts | 13 |
4 files changed, 18 insertions, 18 deletions
diff --git a/build/database.js b/build/database.js index 7c7d192..51171cc 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.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; +exports.updateAccount = exports.fetchAccountFromDiscord = exports.fetchAccount = exports.fetchSession = exports.createSession = exports.finishedCachingRawLeaderboards = exports.queueUpdateDatabaseProfile = exports.queueUpdateDatabaseMember = exports.leaderboardUpdateProfileQueue = exports.leaderboardUpdateMemberQueue = 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"); @@ -502,22 +502,22 @@ async function updateDatabaseProfile(profile) { console.debug('added profile to leaderboards', profile.name, leaderboardAttributes); } exports.updateDatabaseProfile = updateDatabaseProfile; -const leaderboardUpdateMemberQueue = new queue_promise_1.default({ +exports.leaderboardUpdateMemberQueue = new queue_promise_1.default({ concurrent: 1, interval: 2000 }); -const leaderboardUpdateProfileQueue = new queue_promise_1.default({ +exports.leaderboardUpdateProfileQueue = new queue_promise_1.default({ concurrent: 1, interval: 10000 }); /** Queue an update for the member's leaderboard data on the server if applicable */ function queueUpdateDatabaseMember(member, profile) { - leaderboardUpdateMemberQueue.enqueue(async () => await updateDatabaseMember(member, profile)); + exports.leaderboardUpdateMemberQueue.enqueue(async () => await updateDatabaseMember(member, profile)); } exports.queueUpdateDatabaseMember = queueUpdateDatabaseMember; /** Queue an update for the profile's leaderboard data on the server if applicable */ function queueUpdateDatabaseProfile(profile) { - leaderboardUpdateProfileQueue.enqueue(async () => await updateDatabaseProfile(profile)); + exports.leaderboardUpdateProfileQueue.enqueue(async () => await updateDatabaseProfile(profile)); } exports.queueUpdateDatabaseProfile = queueUpdateDatabaseProfile; /** diff --git a/build/index.js b/build/index.js index 62c1f7e..1f628ea 100644 --- a/build/index.js +++ b/build/index.js @@ -56,7 +56,9 @@ app.get('/', async (req, res) => { res.json({ ok: true, uptimeHours: (currentTime - startTime) / 1000 / 60 / 60, - finishedCachingRawLeaderboards: database_1.finishedCachingRawLeaderboards + finishedCachingRawLeaderboards: database_1.finishedCachingRawLeaderboards, + leaderboardUpdateMemberQueueSize: database_1.leaderboardUpdateMemberQueue.size, + leaderboardUpdateProfileQueueSize: database_1.leaderboardUpdateProfileQueue.size, }); }); app.get('/player/:user', async (req, res) => { @@ -88,10 +90,7 @@ app.get('/player/:user/:profile', async (req, res) => { }); app.get('/player/:user/:profile/leaderboards', async (req, res) => { try { - res.json({ ok: false }); - // res.json( - // await fetchMemberLeaderboardSpots(req.params.user, req.params.profile) - // ) + res.json(await database_1.fetchMemberLeaderboardSpots(req.params.user, req.params.profile)); } catch (err) { console.error(err); diff --git a/src/database.ts b/src/database.ts index 577bd6a..661b806 100644 --- a/src/database.ts +++ b/src/database.ts @@ -651,11 +651,11 @@ export async function updateDatabaseProfile(profile: CleanFullProfile): Promise< if (debug) console.debug('added profile to leaderboards', profile.name, leaderboardAttributes) } -const leaderboardUpdateMemberQueue = new Queue({ +export const leaderboardUpdateMemberQueue = new Queue({ concurrent: 1, interval: 2000 }) -const leaderboardUpdateProfileQueue = new Queue({ +export const leaderboardUpdateProfileQueue = new Queue({ concurrent: 1, interval: 10000 }) diff --git a/src/index.ts b/src/index.ts index d6859d4..a4f9a39 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,4 @@ -import { createSession, fetchAccountFromDiscord, fetchAllLeaderboardsCategorized, fetchLeaderboard, fetchMemberLeaderboardSpots, fetchSession, finishedCachingRawLeaderboards, updateAccount } from './database' +import { createSession, fetchAccountFromDiscord, fetchAllLeaderboardsCategorized, fetchLeaderboard, fetchMemberLeaderboardSpots, fetchSession, finishedCachingRawLeaderboards, leaderboardUpdateMemberQueue, leaderboardUpdateProfileQueue, updateAccount } from './database' import { fetchMemberProfile, fetchUser } from './hypixel' import rateLimit from 'express-rate-limit' import * as constants from './constants' @@ -36,7 +36,9 @@ app.get('/', async(req, res) => { res.json({ ok: true, uptimeHours: (currentTime - startTime) / 1000 / 60 / 60, - finishedCachingRawLeaderboards + finishedCachingRawLeaderboards, + leaderboardUpdateMemberQueueSize: leaderboardUpdateMemberQueue.size, + leaderboardUpdateProfileQueueSize: leaderboardUpdateProfileQueue.size, }) }) @@ -79,10 +81,9 @@ app.get('/player/:user/:profile', async(req, res) => { app.get('/player/:user/:profile/leaderboards', async(req, res) => { try { - res.json({ ok: false }) - // res.json( - // await fetchMemberLeaderboardSpots(req.params.user, req.params.profile) - // ) + res.json( + await fetchMemberLeaderboardSpots(req.params.user, req.params.profile) + ) } catch (err) { console.error(err) res.json({ ok: false }) |