From 5933074569ae8b5bc83526127cf478d3868e4bd8 Mon Sep 17 00:00:00 2001
From: Liam
Date: Mon, 21 Oct 2024 13:47:53 +0100
Subject: [PATCH] fix qualified status for leaderboards
---
.../impl/scoresaber-leaderboard.ts | 21 +++++++++++++++++++
.../src/leaderboard/leaderboard-status.ts | 1 +
.../leaderboard/leaderboard-info.tsx | 2 +-
3 files changed, 23 insertions(+), 1 deletion(-)
create mode 100644 projects/common/src/leaderboard/leaderboard-status.ts
diff --git a/projects/common/src/leaderboard/impl/scoresaber-leaderboard.ts b/projects/common/src/leaderboard/impl/scoresaber-leaderboard.ts
index 553de3e..29b7805 100644
--- a/projects/common/src/leaderboard/impl/scoresaber-leaderboard.ts
+++ b/projects/common/src/leaderboard/impl/scoresaber-leaderboard.ts
@@ -3,6 +3,7 @@ import LeaderboardDifficulty from "../leaderboard-difficulty";
import ScoreSaberLeaderboardToken from "../../types/token/scoresaber/score-saber-leaderboard-token";
import { getDifficultyFromScoreSaberDifficulty } from "../../utils/scoresaber-utils";
import { parseDate } from "../../utils/time-utils";
+import { LeaderboardStatus } from "../leaderboard-status";
export default interface ScoreSaberLeaderboard extends Leaderboard {
/**
@@ -19,6 +20,16 @@ export default interface ScoreSaberLeaderboard extends Leaderboard {
* The amount of plays today.
*/
readonly dailyPlays: number;
+
+ /**
+ * Whether this leaderboard is qualified to be ranked.
+ */
+ readonly qualified: boolean;
+
+ /**
+ * The status of the map.
+ */
+ readonly status: LeaderboardStatus;
}
/**
@@ -33,6 +44,14 @@ export function getScoreSaberLeaderboardFromToken(token: ScoreSaberLeaderboardTo
gameMode: token.difficulty.gameMode,
difficultyRaw: token.difficulty.difficultyRaw,
};
+
+ let status: LeaderboardStatus = "Unranked";
+ if (token.qualified) {
+ status = "Qualified";
+ } else if (token.ranked) {
+ status = "Ranked";
+ }
+
return {
id: token.id,
songHash: token.songHash,
@@ -59,5 +78,7 @@ export function getScoreSaberLeaderboardFromToken(token: ScoreSaberLeaderboardTo
stars: token.stars,
plays: token.plays,
dailyPlays: token.dailyPlays,
+ qualified: token.qualified,
+ status: status,
};
}
diff --git a/projects/common/src/leaderboard/leaderboard-status.ts b/projects/common/src/leaderboard/leaderboard-status.ts
new file mode 100644
index 0000000..4934bf9
--- /dev/null
+++ b/projects/common/src/leaderboard/leaderboard-status.ts
@@ -0,0 +1 @@
+export type LeaderboardStatus = "Unranked" | "Ranked" | "Qualified";
diff --git a/projects/website/src/components/leaderboard/leaderboard-info.tsx b/projects/website/src/components/leaderboard/leaderboard-info.tsx
index 83b770a..4fcb50a 100644
--- a/projects/website/src/components/leaderboard/leaderboard-info.tsx
+++ b/projects/website/src/components/leaderboard/leaderboard-info.tsx
@@ -55,7 +55,7 @@ export function LeaderboardInfo({ leaderboard, beatSaverMap }: LeaderboardInfoPr
{formatNumber(leaderboard.dailyPlays)} today)
- Status: {leaderboard.stars > 0 ? "Ranked" : "Unranked"}
+ Status: {leaderboard.status}