cleanup
Some checks failed
Deploy Backend / deploy (push) Failing after 2m2s
Deploy Website / deploy (push) Failing after 1m56s

This commit is contained in:
Lee
2024-10-12 03:37:54 +01:00
parent 97a91d7249
commit f8b97e3471
6 changed files with 32 additions and 14 deletions

View File

@ -3,6 +3,7 @@ import ky from "ky";
import { PlayerHistory } from "../player-history";
import ScoreSaberPlayerToken from "../../token/scoresaber/score-saber-player-token";
import { formatDateMinimal, getDaysAgoDate, getMidnightAlignedDate } from "../../../utils/time-utils";
import { getPageFromRank } from "@ssr/utils/utils";
/**
* A ScoreSaber player.
@ -202,10 +203,6 @@ export async function getScoreSaberPlayerFromToken(
return (statToday - statOther) * (statType == "pp" ? 1 : -1);
};
const getRankPosition = (rank: number): number => {
return Math.floor(rank / 50) + 1;
};
return {
id: token.id,
name: token.name,
@ -238,8 +235,8 @@ export async function getScoreSaberPlayerFromToken(
statisticHistory: statisticHistory,
statistics: token.scoreStats,
rankPages: {
global: getRankPosition(token.rank),
country: getRankPosition(token.countryRank),
global: getPageFromRank(token.rank, 50),
country: getPageFromRank(token.countryRank, 50),
},
permissions: token.permissions,
banned: token.banned,

View File

@ -13,3 +13,14 @@ export function isProduction() {
export function delay(ms: number) {
return new Promise(resolve => setTimeout(resolve, ms));
}
/**
* Gets the page from a rank.
*
* @param rank the rank
* @param itemsPerPage the items per page
* @returns the page
*/
export function getPageFromRank(rank: number, itemsPerPage: number) {
return Math.floor(rank / itemsPerPage) + 1;
}