aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormat <27899617+mat-1@users.noreply.github.com>2021-04-09 11:12:06 -0500
committermat <27899617+mat-1@users.noreply.github.com>2021-04-09 11:12:06 -0500
commitd8199c5dbc9031ddd12a1609d118aef62715d151 (patch)
treef315c19f239523b7861d4cbdcfb48f24fcdc5ec0
parente861e397b51fcad6ce459a7074b7a34fabc61734 (diff)
downloadskyblock-api-d8199c5dbc9031ddd12a1609d118aef62715d151.tar.gz
skyblock-api-d8199c5dbc9031ddd12a1609d118aef62715d151.tar.bz2
skyblock-api-d8199c5dbc9031ddd12a1609d118aef62715d151.zip
fix people not being added to small leaderboards
-rw-r--r--build/database.js4
-rw-r--r--src/database.ts7
2 files changed, 9 insertions, 2 deletions
diff --git a/build/database.js b/build/database.js
index f397c3e..b40d30c 100644
--- a/build/database.js
+++ b/build/database.js
@@ -207,8 +207,10 @@ async function getApplicableAttributes(member) {
for (const [leaderboard, attributeValue] of Object.entries(leaderboardAttributes)) {
const requirement = await getMemberLeaderboardRequirement(leaderboard);
const leaderboardReversed = isLeaderboardReversed(leaderboard);
- if (!requirement || leaderboardReversed ? attributeValue < requirement : attributeValue > requirement)
+ if ((requirement === null)
+ || (leaderboardReversed ? attributeValue < requirement : attributeValue > requirement)) {
applicableAttributes[leaderboard] = attributeValue;
+ }
}
return applicableAttributes;
}
diff --git a/src/database.ts b/src/database.ts
index cfa95ac..9e81f5b 100644
--- a/src/database.ts
+++ b/src/database.ts
@@ -224,6 +224,7 @@ export async function fetchMemberLeaderboardSpots(player: string, profile: strin
async function getMemberLeaderboardRequirement(name: string): Promise<number> {
const leaderboard = await fetchMemberLeaderboardRaw(name)
+
// if there's more than 100 items, return the 100th. if there's less, return null
if (leaderboard.length >= leaderboardMax)
return leaderboard[leaderboardMax - 1].stats[name]
@@ -238,8 +239,12 @@ async function getApplicableAttributes(member: CleanMember): Promise<StringNumbe
for (const [ leaderboard, attributeValue ] of Object.entries(leaderboardAttributes)) {
const requirement = await getMemberLeaderboardRequirement(leaderboard)
const leaderboardReversed = isLeaderboardReversed(leaderboard)
- if (!requirement || leaderboardReversed ? attributeValue < requirement : attributeValue > requirement)
+ if (
+ (requirement === null)
+ || (leaderboardReversed ? attributeValue < requirement : attributeValue > requirement)
+ ) {
applicableAttributes[leaderboard] = attributeValue
+ }
}
return applicableAttributes
}