diff options
author | mat <github@matdoes.dev> | 2021-05-24 14:23:22 -0500 |
---|---|---|
committer | mat <github@matdoes.dev> | 2021-05-24 14:23:22 -0500 |
commit | 2ba6657d66d618ecc3ae8c7705de31fd8315599c (patch) | |
tree | e38f46182138b7e7a9bb8e6e155dc4e5dada1b34 | |
parent | 7fa239e3a0c2a27bb4619bb104284e430ae613fd (diff) | |
download | skyblock-api-2ba6657d66d618ecc3ae8c7705de31fd8315599c.tar.gz skyblock-api-2ba6657d66d618ecc3ae8c7705de31fd8315599c.tar.bz2 skyblock-api-2ba6657d66d618ecc3ae8c7705de31fd8315599c.zip |
Revert "disable leaderboards"
This reverts commit 17866766304a9049dda716a21d94bcd4803980a7.
-rw-r--r-- | build/database.js | 35 | ||||
-rw-r--r-- | src/database.ts | 35 |
2 files changed, 10 insertions, 60 deletions
diff --git a/build/database.js b/build/database.js index 18a78f7..aa8765c 100644 --- a/build/database.js +++ b/build/database.js @@ -115,7 +115,6 @@ function getProfileLeaderboardAttributes(profile) { }; } async function fetchAllLeaderboardsCategorized() { - return {}; const memberLeaderboardAttributes = await fetchAllMemberLeaderboardAttributes(); const profileLeaderboardAttributes = await fetchAllProfileLeaderboardAttributes(); const categorizedLeaderboards = {}; @@ -134,7 +133,6 @@ async function fetchAllLeaderboardsCategorized() { exports.fetchAllLeaderboardsCategorized = fetchAllLeaderboardsCategorized; /** Fetch the raw names for the slayer leaderboards */ async function fetchSlayerLeaderboards() { - return []; const rawSlayerNames = await constants.fetchSlayers(); let leaderboardNames = [ 'slayer_total_xp', @@ -153,7 +151,6 @@ async function fetchSlayerLeaderboards() { exports.fetchSlayerLeaderboards = fetchSlayerLeaderboards; /** Fetch the names of all the leaderboards that rank members */ async function fetchAllMemberLeaderboardAttributes() { - return []; return [ // we use the raw stat names rather than the clean stats in case hypixel adds a new stat and it takes a while for us to clean it ...await constants.fetchStats(), @@ -189,7 +186,6 @@ function isLeaderboardReversed(name) { return false; } async function fetchMemberLeaderboardRaw(name) { - return []; if (!client) throw Error('Client isn\'t initialized yet'); if (cachedRawLeaderboards.has(name)) @@ -208,7 +204,6 @@ async function fetchMemberLeaderboardRaw(name) { return leaderboardRaw; } async function fetchProfileLeaderboardRaw(name) { - return []; if (cachedRawLeaderboards.has(name)) return cachedRawLeaderboards.get(name); // typescript forces us to make a new variable and set it this way because it gives an error otherwise @@ -227,11 +222,6 @@ async function fetchProfileLeaderboardRaw(name) { /** Fetch a leaderboard that ranks members, as opposed to profiles */ async function fetchMemberLeaderboard(name) { var _a; - return { - list: [], - name: 'Leaderboards are temporarily disabled, they\'ll be back in a few hours', - unit: '' - }; const leaderboardRaw = await fetchMemberLeaderboardRaw(name); const fetchLeaderboardPlayer = async (item) => { return { @@ -255,11 +245,6 @@ exports.fetchMemberLeaderboard = fetchMemberLeaderboard; /** Fetch a leaderboard that ranks profiles, as opposed to members */ async function fetchProfileLeaderboard(name) { var _a; - return { - list: [], - name: 'Leaderboards are temporarily disabled, they\'ll be back in a few hours', - unit: '' - }; const leaderboardRaw = await fetchProfileLeaderboardRaw(name); const fetchLeaderboardProfile = async (item) => { const players = []; @@ -285,11 +270,6 @@ async function fetchProfileLeaderboard(name) { exports.fetchProfileLeaderboard = fetchProfileLeaderboard; /** Fetch a leaderboard */ async function fetchLeaderboard(name) { - return { - list: [], - name: 'Leaderboards are temporarily disabled, they\'ll be back in a few hours', - unit: '' - }; const profileLeaderboards = await fetchAllProfileLeaderboardAttributes(); if (profileLeaderboards.includes(name)) { return await fetchProfileLeaderboard(name); @@ -302,7 +282,6 @@ exports.fetchLeaderboard = fetchLeaderboard; /** Get the leaderboard positions a member is on. This may take a while depending on whether stuff is cached */ async function fetchMemberLeaderboardSpots(player, profile) { var _a; - return []; const fullProfile = await cached.fetchProfile(player, profile); const fullMember = fullProfile.members.find(m => m.username.toLowerCase() === player.toLowerCase() || m.uuid === player); // update the leaderboard positions for the member @@ -336,7 +315,6 @@ async function getLeaderboardRequirement(name, leaderboardType) { } /** Get the attributes for the member, but only ones that would put them on the top 100 for leaderboards */ async function getApplicableMemberLeaderboardAttributes(member) { - return {}; const leaderboardAttributes = getMemberLeaderboardAttributes(member); const applicableAttributes = {}; for (const [leaderboard, attributeValue] of Object.entries(leaderboardAttributes)) { @@ -357,7 +335,6 @@ async function getApplicableMemberLeaderboardAttributes(member) { } /** Get the attributes for the profile, but only ones that would put them on the top 100 for leaderboards */ async function getApplicableProfileLeaderboardAttributes(profile) { - return {}; const leaderboardAttributes = getProfileLeaderboardAttributes(profile); const applicableAttributes = {}; for (const [leaderboard, attributeValue] of Object.entries(leaderboardAttributes)) { @@ -378,7 +355,6 @@ async function getApplicableProfileLeaderboardAttributes(profile) { } /** Update the member's leaderboard data on the server if applicable */ async function updateDatabaseMember(member, profile) { - return; if (!client) return; // the db client hasn't been initialized if (_1.debug) @@ -434,7 +410,6 @@ exports.updateDatabaseMember = updateDatabaseMember; * This will not also update the members, you have to call updateDatabaseMember separately for that */ async function updateDatabaseProfile(profile) { - return; if (!client) return; // the db client hasn't been initialized if (_1.debug) @@ -489,12 +464,12 @@ const leaderboardUpdateProfileQueue = new queue_promise_1.default({ }); /** Queue an update for the member's leaderboard data on the server if applicable */ async function queueUpdateDatabaseMember(member, profile) { - // leaderboardUpdateMemberQueue.enqueue(async() => await updateDatabaseMember(member, profile)) + leaderboardUpdateMemberQueue.enqueue(async () => await updateDatabaseMember(member, profile)); } exports.queueUpdateDatabaseMember = queueUpdateDatabaseMember; /** Queue an update for the profile's leaderboard data on the server if applicable */ async function queueUpdateDatabaseProfile(profile) { - // leaderboardUpdateProfileQueue.enqueue(async() => await updateDatabaseProfile(profile)) + leaderboardUpdateProfileQueue.enqueue(async () => await updateDatabaseProfile(profile)); } exports.queueUpdateDatabaseProfile = queueUpdateDatabaseProfile; /** @@ -541,10 +516,10 @@ async function fetchAllLeaderboards(fast) { if (!globalThis.isTest) { connect().then(() => { // when it connects, cache the leaderboards and remove bad members - // removeBadMemberLeaderboardAttributes() + removeBadMemberLeaderboardAttributes(); // cache leaderboards on startup so its faster later on - // fetchAllLeaderboards(true) + fetchAllLeaderboards(true); // cache leaderboard players again every 4 hours - // setInterval(fetchAllLeaderboards, 4 * 60 * 60 * 1000) + setInterval(fetchAllLeaderboards, 4 * 60 * 60 * 1000); }); } diff --git a/src/database.ts b/src/database.ts index c317be7..35c04e8 100644 --- a/src/database.ts +++ b/src/database.ts @@ -141,7 +141,6 @@ function getProfileLeaderboardAttributes(profile: CleanFullProfile): StringNumbe export async function fetchAllLeaderboardsCategorized(): Promise<{ [ category: string ]: string[] }> { - return {} const memberLeaderboardAttributes: string[] = await fetchAllMemberLeaderboardAttributes() const profileLeaderboardAttributes: string[] = await fetchAllProfileLeaderboardAttributes() @@ -163,7 +162,6 @@ export async function fetchAllLeaderboardsCategorized(): Promise<{ [ category: s /** Fetch the raw names for the slayer leaderboards */ export async function fetchSlayerLeaderboards(): Promise<string[]> { - return [] const rawSlayerNames = await constants.fetchSlayers() let leaderboardNames: string[] = [ 'slayer_total_xp', @@ -184,7 +182,6 @@ export async function fetchSlayerLeaderboards(): Promise<string[]> { /** Fetch the names of all the leaderboards that rank members */ export async function fetchAllMemberLeaderboardAttributes(): Promise<string[]> { - return [] return [ // we use the raw stat names rather than the clean stats in case hypixel adds a new stat and it takes a while for us to clean it ...await constants.fetchStats(), @@ -228,7 +225,6 @@ function isLeaderboardReversed(name: string): boolean { } async function fetchMemberLeaderboardRaw(name: string): Promise<DatabaseMemberLeaderboardItem[]> { - return [] if (!client) throw Error('Client isn\'t initialized yet') if (cachedRawLeaderboards.has(name)) @@ -251,7 +247,6 @@ async function fetchMemberLeaderboardRaw(name: string): Promise<DatabaseMemberLe } async function fetchProfileLeaderboardRaw(name: string): Promise<DatabaseProfileLeaderboardItem[]> { - return [] if (cachedRawLeaderboards.has(name)) return cachedRawLeaderboards.get(name) as DatabaseProfileLeaderboardItem[] // typescript forces us to make a new variable and set it this way because it gives an error otherwise @@ -286,11 +281,6 @@ interface ProfileLeaderboard { /** Fetch a leaderboard that ranks members, as opposed to profiles */ export async function fetchMemberLeaderboard(name: string): Promise<MemberLeaderboard> { - return { - list: [], - name: 'Leaderboards are temporarily disabled, they\'ll be back in a few hours', - unit: '' - } const leaderboardRaw = await fetchMemberLeaderboardRaw(name) const fetchLeaderboardPlayer = async(item: DatabaseMemberLeaderboardItem): Promise<MemberLeaderboardItem> => { @@ -315,11 +305,6 @@ export async function fetchMemberLeaderboard(name: string): Promise<MemberLeader /** Fetch a leaderboard that ranks profiles, as opposed to members */ export async function fetchProfileLeaderboard(name: string): Promise<ProfileLeaderboard> { - return { - list: [], - name: 'Leaderboards are temporarily disabled, they\'ll be back in a few hours', - unit: '' - } const leaderboardRaw = await fetchProfileLeaderboardRaw(name) const fetchLeaderboardProfile = async(item: DatabaseProfileLeaderboardItem): Promise<ProfileLeaderboardItem> => { @@ -346,11 +331,6 @@ export async function fetchProfileLeaderboard(name: string): Promise<ProfileLead /** Fetch a leaderboard */ export async function fetchLeaderboard(name: string): Promise<MemberLeaderboard|ProfileLeaderboard> { - return { - list: [], - name: 'Leaderboards are temporarily disabled, they\'ll be back in a few hours', - unit: '' - } const profileLeaderboards = await fetchAllProfileLeaderboardAttributes() if (profileLeaderboards.includes(name)) { return await fetchProfileLeaderboard(name) @@ -361,7 +341,6 @@ export async function fetchLeaderboard(name: string): Promise<MemberLeaderboard| /** Get the leaderboard positions a member is on. This may take a while depending on whether stuff is cached */ export async function fetchMemberLeaderboardSpots(player: string, profile: string) { - return [] const fullProfile = await cached.fetchProfile(player, profile) const fullMember = fullProfile.members.find(m => m.username.toLowerCase() === player.toLowerCase() || m.uuid === player) @@ -403,7 +382,6 @@ async function getLeaderboardRequirement(name: string, leaderboardType: 'member' /** Get the attributes for the member, but only ones that would put them on the top 100 for leaderboards */ async function getApplicableMemberLeaderboardAttributes(member: CleanMember): Promise<StringNumber> { - return {} const leaderboardAttributes = getMemberLeaderboardAttributes(member) const applicableAttributes = {} @@ -434,7 +412,6 @@ async function getApplicableMemberLeaderboardAttributes(member: CleanMember): Pr /** Get the attributes for the profile, but only ones that would put them on the top 100 for leaderboards */ async function getApplicableProfileLeaderboardAttributes(profile: CleanFullProfile): Promise<StringNumber> { - return {} const leaderboardAttributes = getProfileLeaderboardAttributes(profile) const applicableAttributes = {} @@ -465,7 +442,6 @@ async function getApplicableProfileLeaderboardAttributes(profile: CleanFullProfi /** Update the member's leaderboard data on the server if applicable */ export async function updateDatabaseMember(member: CleanMember, profile: CleanFullProfile): Promise<void> { - return if (!client) return // the db client hasn't been initialized if (debug) console.debug('updateDatabaseMember', member.username) // the member's been updated too recently, just return @@ -527,7 +503,6 @@ export async function updateDatabaseMember(member: CleanMember, profile: CleanFu * This will not also update the members, you have to call updateDatabaseMember separately for that */ export async function updateDatabaseProfile(profile: CleanFullProfile): Promise<void> { - return if (!client) return // the db client hasn't been initialized if (debug) console.debug('updateDatabaseProfile', profile.name) @@ -589,12 +564,12 @@ const leaderboardUpdateProfileQueue = new Queue({ /** Queue an update for the member's leaderboard data on the server if applicable */ export async function queueUpdateDatabaseMember(member: CleanMember, profile: CleanFullProfile): Promise<void> { - // leaderboardUpdateMemberQueue.enqueue(async() => await updateDatabaseMember(member, profile)) + leaderboardUpdateMemberQueue.enqueue(async() => await updateDatabaseMember(member, profile)) } /** Queue an update for the profile's leaderboard data on the server if applicable */ export async function queueUpdateDatabaseProfile(profile: CleanFullProfile): Promise<void> { - // leaderboardUpdateProfileQueue.enqueue(async() => await updateDatabaseProfile(profile)) + leaderboardUpdateProfileQueue.enqueue(async() => await updateDatabaseProfile(profile)) } @@ -649,10 +624,10 @@ async function fetchAllLeaderboards(fast?: boolean): Promise<void> { if (!globalThis.isTest) { connect().then(() => { // when it connects, cache the leaderboards and remove bad members - // removeBadMemberLeaderboardAttributes() + removeBadMemberLeaderboardAttributes() // cache leaderboards on startup so its faster later on - // fetchAllLeaderboards(true) + fetchAllLeaderboards(true) // cache leaderboard players again every 4 hours - // setInterval(fetchAllLeaderboards, 4 * 60 * 60 * 1000) + setInterval(fetchAllLeaderboards, 4 * 60 * 60 * 1000) }) } |