fix qualified status for leaderboards
Some checks failed
Deploy Backend / docker (ubuntu-latest) (push) Successful in 45s
Deploy Website / docker (ubuntu-latest) (push) Failing after 59s

This commit is contained in:
Lee 2024-10-21 13:47:53 +01:00
parent af8c87f5af
commit 5933074569
3 changed files with 23 additions and 1 deletions

@ -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,
};
}

@ -0,0 +1 @@
export type LeaderboardStatus = "Unranked" | "Ranked" | "Qualified";

@ -55,7 +55,7 @@ export function LeaderboardInfo({ leaderboard, beatSaverMap }: LeaderboardInfoPr
{formatNumber(leaderboard.dailyPlays)} today)
</p>
<p>
Status: <span className="font-semibold">{leaderboard.stars > 0 ? "Ranked" : "Unranked"}</span>
Status: <span className="font-semibold">{leaderboard.status}</span>
</p>
</div>
</div>