aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormat <github@matdoes.dev>2021-08-06 01:52:44 -0500
committermat <github@matdoes.dev>2021-08-06 01:52:44 -0500
commit940433a9eed72796072e2ad448ba5f236c55de10 (patch)
treed0abd9cf4f1cac8f0f1f21b28d7e21e528bc34c7
parentf328daa61e27e75e9a0e77947fb2b9b37ec421e8 (diff)
downloadskyblock-api-940433a9eed72796072e2ad448ba5f236c55de10.tar.gz
skyblock-api-940433a9eed72796072e2ad448ba5f236c55de10.tar.bz2
skyblock-api-940433a9eed72796072e2ad448ba5f236c55de10.zip
don't add players to leaderboards leaderboards when they aren't on any
-rw-r--r--build/database.js10
-rw-r--r--src/database.ts16
2 files changed, 17 insertions, 9 deletions
diff --git a/build/database.js b/build/database.js
index 8543901..a12fc9e 100644
--- a/build/database.js
+++ b/build/database.js
@@ -403,14 +403,16 @@ async function getApplicableMemberLeaderboardAttributes(member) {
// add the "leaderboards count" attribute
const leaderboardsCount = Object.keys(applicableAttributes).length;
const leaderboardsCountRequirement = await getLeaderboardRequirement('leaderboards_count', 'member');
- if ((leaderboardsCountRequirement.top_100 === null)
- || (leaderboardsCount > leaderboardsCountRequirement.top_100))
+ if (leaderboardsCount > 0
+ && ((leaderboardsCountRequirement.top_100 === null)
+ || (leaderboardsCount > leaderboardsCountRequirement.top_100)))
applicableAttributes['leaderboards_count'] = leaderboardsCount;
// add the "first leaderboards count" attribute
const top1LeaderboardsCount = Object.keys(applicableTop1Attributes).length;
const top1LeaderboardsCountRequirement = await getLeaderboardRequirement('top_1_leaderboards_count', 'member');
- if ((top1LeaderboardsCountRequirement.top_100 === null)
- || (top1LeaderboardsCount > top1LeaderboardsCountRequirement.top_100))
+ if (top1LeaderboardsCount > 0
+ && ((top1LeaderboardsCountRequirement.top_100 === null)
+ || (top1LeaderboardsCount > top1LeaderboardsCountRequirement.top_100)))
applicableAttributes['top_1_leaderboards_count'] = top1LeaderboardsCount;
return applicableAttributes;
}
diff --git a/src/database.ts b/src/database.ts
index 9bc7cda..0e16d48 100644
--- a/src/database.ts
+++ b/src/database.ts
@@ -532,8 +532,11 @@ async function getApplicableMemberLeaderboardAttributes(member: CleanMember): Pr
const leaderboardsCountRequirement = await getLeaderboardRequirement('leaderboards_count', 'member')
if (
- (leaderboardsCountRequirement.top_100 === null)
- || (leaderboardsCount > leaderboardsCountRequirement.top_100)
+ leaderboardsCount > 0
+ && (
+ (leaderboardsCountRequirement.top_100 === null)
+ || (leaderboardsCount > leaderboardsCountRequirement.top_100)
+ )
)
applicableAttributes['leaderboards_count'] = leaderboardsCount
@@ -542,10 +545,13 @@ async function getApplicableMemberLeaderboardAttributes(member: CleanMember): Pr
const top1LeaderboardsCountRequirement = await getLeaderboardRequirement('top_1_leaderboards_count', 'member')
if (
- (top1LeaderboardsCountRequirement.top_100 === null)
- || (top1LeaderboardsCount > top1LeaderboardsCountRequirement.top_100)
+ top1LeaderboardsCount > 0
+ && (
+ (top1LeaderboardsCountRequirement.top_100 === null)
+ || (top1LeaderboardsCount > top1LeaderboardsCountRequirement.top_100)
+ )
)
- applicableAttributes['top_1_leaderboards_count'] = top1LeaderboardsCount
+ applicableAttributes['top_1_leaderboards_count'] = top1LeaderboardsCount
return applicableAttributes
}