diff options
author | mat <27899617+mat-1@users.noreply.github.com> | 2021-02-28 16:10:02 -0600 |
---|---|---|
committer | mat <27899617+mat-1@users.noreply.github.com> | 2021-02-28 16:10:02 -0600 |
commit | dfd4016d4ea907719d0b4edf28e4b9529534870c (patch) | |
tree | 4f96fb0e54a6bdea021fd9eb1cbc391d3accdf30 /src/database.ts | |
parent | b69690f7cf2405bc817082cce45185fb389d0bb9 (diff) | |
download | skyblock-api-dfd4016d4ea907719d0b4edf28e4b9529534870c.tar.gz skyblock-api-dfd4016d4ea907719d0b4edf28e4b9529534870c.tar.bz2 skyblock-api-dfd4016d4ea907719d0b4edf28e4b9529534870c.zip |
make /leaderboards include categories
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 [ |