aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md7
-rw-r--r--src/cleaners/skyblock/member.ts8
-rw-r--r--src/cleaners/skyblock/profile.ts10
3 files changed, 15 insertions, 10 deletions
diff --git a/README.md b/README.md
index 6390ac5..f0035e0 100644
--- a/README.md
+++ b/README.md
@@ -13,3 +13,10 @@ This is kinda like [Slothpixel](https://github.com/slothpixel/core), as in it fe
5) hypixel.ts calls one or more of the cleaners, which pretties up the data for us to use
6) cleaned data is returned to hypixelCached, which will cache it
7) Data is sent back to express to serve to the user
+
+## API conventions
+
+If you (this is really just here for myself so I don't forget) are adding a new API thing, follow these rules so the API is consistent with how it responds:
+- Use camelCase. Some old things use snake_case but these are going to be changed at some point.
+- Prefer arrays over dictionaries when the keys aren't static. For example `[ { name: "asdf", value: "dsfasg" } ]` rather than `{ "asdf": "dsfasg" }`.
+- Idk I'll add more to here later
diff --git a/src/cleaners/skyblock/member.ts b/src/cleaners/skyblock/member.ts
index 932b016..8d1fdf1 100644
--- a/src/cleaners/skyblock/member.ts
+++ b/src/cleaners/skyblock/member.ts
@@ -27,9 +27,8 @@ export interface CleanBasicMember {
export interface CleanMember extends CleanBasicMember {
purse: number
stats: StatItem[]
- rawHypixelStats?: { [ key: string ]: number }
+ rawHypixelStats?: { [key: string]: number }
minions: CleanMinion[]
- max_minions: number
fairy_souls: FairySouls
inventories?: Inventories
objectives: Objective[]
@@ -62,8 +61,6 @@ export async function cleanSkyBlockProfileMemberResponse(member, included: Inclu
const { max_fairy_souls: maxFairySouls } = await constants.fetchConstantValues()
if (fairySouls.total > (maxFairySouls ?? 0))
await constants.setConstantValues({ max_fairy_souls: fairySouls.total })
-
- const { max_minions } = await constants.fetchConstantValues()
return {
uuid: member.uuid,
@@ -80,7 +77,6 @@ export async function cleanSkyBlockProfileMemberResponse(member, included: Inclu
rawHypixelStats: member.stats ?? {},
minions: await cleanMinions(member),
- max_minions: max_minions ?? 0,
fairy_souls: fairySouls,
inventories: inventoriesIncluded ? await cleanInventories(member) : undefined,
objectives: cleanObjectives(member),
@@ -100,7 +96,7 @@ export interface CleanMemberProfilePlayer extends CleanPlayer {
bank?: Bank
purse?: number
stats?: StatItem[]
- rawHypixelStats?: { [ key: string ]: number }
+ rawHypixelStats?: { [key: string]: number }
minions?: CleanMinion[]
fairy_souls?: FairySouls
inventories?: Inventories
diff --git a/src/cleaners/skyblock/profile.ts b/src/cleaners/skyblock/profile.ts
index 34c895a..a7bc92a 100644
--- a/src/cleaners/skyblock/profile.ts
+++ b/src/cleaners/skyblock/profile.ts
@@ -12,14 +12,15 @@ export interface CleanFullProfile extends CleanProfile {
members: CleanMember[]
bank: Bank
minions: CleanMinion[]
- minion_count: number
+ minion_count: number
+ maxUniqueMinions: number
}
export interface CleanFullProfileBasicMembers extends CleanProfile {
members: CleanBasicMember[]
bank: Bank
minions: CleanMinion[]
- minion_count: number
+ minion_count: number
}
/** Return a `CleanProfile` instead of a `CleanFullProfile`, useful when we need to get members but don't want to waste much ram */
@@ -80,7 +81,7 @@ export async function cleanSkyblockProfileResponse(data: any, options?: ApiOptio
const minions: CleanMinion[] = combineMinionArrays(memberMinions)
const { max_minions: maxUniqueMinions } = await constants.fetchConstantValues()
-
+
const uniqueMinions = countUniqueMinions(minions)
if (uniqueMinions > (maxUniqueMinions ?? 0))
await constants.setConstantValues({ max_minions: uniqueMinions })
@@ -92,7 +93,8 @@ export async function cleanSkyblockProfileResponse(data: any, options?: ApiOptio
members: cleanedMembers,
bank: cleanBank(data),
minions: minions,
- minion_count: uniqueMinions
+ minion_count: uniqueMinions,
+ maxUniqueMinions: maxUniqueMinions ?? 0,
}
}