aboutsummaryrefslogtreecommitdiff
path: root/build/database.js
diff options
context:
space:
mode:
authormat <27899617+mat-1@users.noreply.github.com>2021-02-28 16:10:02 -0600
committermat <27899617+mat-1@users.noreply.github.com>2021-02-28 16:10:02 -0600
commitdfd4016d4ea907719d0b4edf28e4b9529534870c (patch)
tree4f96fb0e54a6bdea021fd9eb1cbc391d3accdf30 /build/database.js
parentb69690f7cf2405bc817082cce45185fb389d0bb9 (diff)
downloadskyblock-api-dfd4016d4ea907719d0b4edf28e4b9529534870c.tar.gz
skyblock-api-dfd4016d4ea907719d0b4edf28e4b9529534870c.tar.bz2
skyblock-api-dfd4016d4ea907719d0b4edf28e4b9529534870c.zip
make /leaderboards include categories
Diffstat (limited to 'build/database.js')
-rw-r--r--build/database.js18
1 files changed, 17 insertions, 1 deletions
diff --git a/build/database.js b/build/database.js
index 1edb990..a813a78 100644
--- a/build/database.js
+++ b/build/database.js
@@ -25,12 +25,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
-exports.updateDatabaseMember = exports.fetchMemberLeaderboard = void 0;
+exports.updateDatabaseMember = exports.fetchMemberLeaderboard = exports.fetchAllMemberLeaderboardAttributes = exports.fetchAllLeaderboardsCategoriezed = void 0;
const constants = __importStar(require("./constants"));
const cached = __importStar(require("./hypixelCached"));
const mongodb_1 = require("mongodb");
const node_cache_1 = __importDefault(require("node-cache"));
const util_1 = require("./util");
+const stats_1 = require("./cleaners/skyblock/stats");
// don't update the user for 3 minutes
const recentlyUpdated = new node_cache_1.default({
stdTTL: 60 * 3,
@@ -73,6 +74,20 @@ function getMemberLeaderboardAttributes(member) {
visited_zones: member.visited_zones.length,
};
}
+async function fetchAllLeaderboardsCategoriezed() {
+ const memberLeaderboardAttributes = await fetchAllMemberLeaderboardAttributes();
+ const categorizedLeaderboards = [];
+ for (const leaderboard of memberLeaderboardAttributes) {
+ const { category, name } = stats_1.categorizeStat(leaderboard);
+ categorizedLeaderboards.push({
+ category,
+ name,
+ id: leaderboard
+ });
+ }
+ return categorizedLeaderboards;
+}
+exports.fetchAllLeaderboardsCategoriezed = fetchAllLeaderboardsCategoriezed;
/** Fetch the names of all the leaderboards */
async function fetchAllMemberLeaderboardAttributes() {
return [
@@ -86,6 +101,7 @@ async function fetchAllMemberLeaderboardAttributes() {
'visited_zones',
];
}
+exports.fetchAllMemberLeaderboardAttributes = fetchAllMemberLeaderboardAttributes;
async function fetchMemberLeaderboardRaw(name) {
if (cachedRawLeaderboards.has(name))
return cachedRawLeaderboards.get(name);