diff options
author | mat <27899617+mat-1@users.noreply.github.com> | 2021-02-28 01:23:18 -0600 |
---|---|---|
committer | mat <27899617+mat-1@users.noreply.github.com> | 2021-02-28 01:23:18 -0600 |
commit | 6dadf95683a8b8574976c9d024b0b148521012f7 (patch) | |
tree | edd88502959e8b74c76d47a82a5b98a646b26eb4 /src/cleaners/skyblock/profile.ts | |
parent | 78198ac4812f6f33f412bdc62216567aa08d8199 (diff) | |
download | skyblock-api-6dadf95683a8b8574976c9d024b0b148521012f7.tar.gz skyblock-api-6dadf95683a8b8574976c9d024b0b148521012f7.tar.bz2 skyblock-api-6dadf95683a8b8574976c9d024b0b148521012f7.zip |
Add leaderboards
Diffstat (limited to 'src/cleaners/skyblock/profile.ts')
-rw-r--r-- | src/cleaners/skyblock/profile.ts | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/src/cleaners/skyblock/profile.ts b/src/cleaners/skyblock/profile.ts index 2b092a1..6e98f8f 100644 --- a/src/cleaners/skyblock/profile.ts +++ b/src/cleaners/skyblock/profile.ts @@ -8,7 +8,14 @@ export interface CleanProfile extends CleanBasicProfile { } export interface CleanFullProfile extends CleanProfile { - members: (CleanMember|CleanBasicMember)[] + members: CleanMember[] + bank: Bank + minions: CleanMinion[] + minion_count: number +} + +export interface CleanFullProfileBasicMembers extends CleanProfile { + members: CleanBasicMember[] bank: Bank minions: CleanMinion[] minion_count: number @@ -38,19 +45,21 @@ export async function cleanSkyblockProfileResponseLighter(data): Promise<CleanPr /** * This function is somewhat costly and shouldn't be called often. Use cleanSkyblockProfileResponseLighter if you don't need all the data */ -export async function cleanSkyblockProfileResponse(data: any, { mainMemberUuid }: ApiOptions): Promise<CleanFullProfile> { - const cleanedMembers: CleanMember[] = [] - +export async function cleanSkyblockProfileResponse(data: any, options?: ApiOptions): Promise<CleanFullProfile> { + // We use Promise.all so it can fetch all the users at once instead of waiting for the previous promise to complete + const promises: Promise<CleanMember>[] = [] + for (const memberUUID in data.members) { const memberRaw = data.members[memberUUID] memberRaw.uuid = memberUUID - const member: CleanMember = await cleanSkyBlockProfileMemberResponse( + promises.push(cleanSkyBlockProfileMemberResponse( memberRaw, - ['stats', mainMemberUuid === memberUUID ? 'inventories' : undefined] - ) - cleanedMembers.push(member) + ['stats', options?.mainMemberUuid === memberUUID ? 'inventories' : undefined] + )) } + const cleanedMembers: CleanMember[] = await Promise.all(promises) + const memberMinions: CleanMinion[][] = [] for (const member of cleanedMembers) { |