From d8199c5dbc9031ddd12a1609d118aef62715d151 Mon Sep 17 00:00:00 2001 From: mat <27899617+mat-1@users.noreply.github.com> Date: Fri, 9 Apr 2021 11:12:06 -0500 Subject: fix people not being added to small leaderboards --- build/database.js | 4 +++- src/database.ts | 7 ++++++- 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 { 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 requirement) + if ( + (requirement === null) + || (leaderboardReversed ? attributeValue < requirement : attributeValue > requirement) + ) { applicableAttributes[leaderboard] = attributeValue + } } return applicableAttributes } -- cgit