diff options
Diffstat (limited to 'src/database.ts')
-rw-r--r-- | src/database.ts | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/database.ts b/src/database.ts index 7cc2f46..b6507cc 100644 --- a/src/database.ts +++ b/src/database.ts @@ -10,6 +10,7 @@ import { CleanMember } from './cleaners/skyblock/member' import { CleanPlayer } from './cleaners/player' import { shuffle } from './util' import { CleanFullProfile } from './cleaners/skyblock/profile' +import { categorizeStat, StatCategory } from './cleaners/skyblock/stats' // don't update the user for 3 minutes const recentlyUpdated = new NodeCache({ @@ -75,6 +76,25 @@ function getMemberLeaderboardAttributes(member: CleanMember) { } } +interface CategorizedLeaderboard extends StatCategory { + id: string +} + +export async function fetchAllLeaderboardsCategoriezed(): Promise<CategorizedLeaderboard[]> { + const memberLeaderboardAttributes = await fetchAllMemberLeaderboardAttributes() + const categorizedLeaderboards: CategorizedLeaderboard[] = [] + for (const leaderboard of memberLeaderboardAttributes) { + const { category, name } = categorizeStat(leaderboard) + categorizedLeaderboards.push({ + category, + name, + id: leaderboard + }) + } + return categorizedLeaderboards +} + + /** Fetch the names of all the leaderboards */ export async function fetchAllMemberLeaderboardAttributes(): Promise<string[]> { return [ |