diff --git a/projects/backend/src/service/leaderboard.service.ts b/projects/backend/src/service/leaderboard.service.ts index 3431ba3..171c1ed 100644 --- a/projects/backend/src/service/leaderboard.service.ts +++ b/projects/backend/src/service/leaderboard.service.ts @@ -6,7 +6,8 @@ import { NotFoundError } from "elysia"; import BeatSaverService from "./beatsaver.service"; import { BeatSaverMap } from "@ssr/common/model/beatsaver/map"; import { getScoreSaberLeaderboardFromToken } from "@ssr/common/token-creators"; -import ScoreSaberLeaderboard, { +import { + ScoreSaberLeaderboard, ScoreSaberLeaderboardModel, } from "@ssr/common/model/leaderboard/impl/scoresaber-leaderboard"; import Leaderboard from "@ssr/common/model/leaderboard/leaderboard"; @@ -46,11 +47,12 @@ export default class LeaderboardService { let foundLeaderboard = false; const cachedLeaderboard = await ScoreSaberLeaderboardModel.findById(id); if (cachedLeaderboard != null) { - leaderboard = cachedLeaderboard as unknown as ScoreSaberLeaderboard; + leaderboard = cachedLeaderboard.toObject() as unknown as ScoreSaberLeaderboard; if ( - leaderboard.ranked || // Never refresh ranked leaderboards (it will get refreshed every night) - leaderboard.lastRefreshed == undefined || // Refresh if it has never been refreshed - now.getTime() - leaderboard.lastRefreshed.getTime() > 1000 * 60 * 60 * 24 // Refresh every day + leaderboard && + (leaderboard.ranked || // Never refresh ranked leaderboards (it will get refreshed every night) + leaderboard.lastRefreshed == undefined || // Refresh if it has never been refreshed + now.getTime() - leaderboard.lastRefreshed.getTime() > 1000 * 60 * 60 * 24) // Refresh every day ) { foundLeaderboard = true; } diff --git a/projects/common/src/model/leaderboard/impl/scoresaber-leaderboard.ts b/projects/common/src/model/leaderboard/impl/scoresaber-leaderboard.ts index df6a20d..c4ed2a3 100644 --- a/projects/common/src/model/leaderboard/impl/scoresaber-leaderboard.ts +++ b/projects/common/src/model/leaderboard/impl/scoresaber-leaderboard.ts @@ -18,7 +18,7 @@ import { Document } from "mongoose"; }, }, }) -export default class ScoreSaberLeaderboard extends Leaderboard { +export default class ScoreSaberLeaderboardInternal extends Leaderboard { /** * The star count for the leaderboard. */ @@ -50,6 +50,7 @@ export default class ScoreSaberLeaderboard extends Leaderboard { readonly status!: LeaderboardStatus; } +export type ScoreSaberLeaderboard = InstanceType; export type ScoreSaberLeaderboardDocument = ScoreSaberLeaderboard & Document; -export const ScoreSaberLeaderboardModel: ReturnModelType = - getModelForClass(ScoreSaberLeaderboard); +export const ScoreSaberLeaderboardModel: ReturnModelType = + getModelForClass(ScoreSaberLeaderboardInternal); diff --git a/projects/website/src/components/leaderboard/leaderboard-scores.tsx b/projects/website/src/components/leaderboard/leaderboard-scores.tsx index e0d9708..df03545 100644 --- a/projects/website/src/components/leaderboard/leaderboard-scores.tsx +++ b/projects/website/src/components/leaderboard/leaderboard-scores.tsx @@ -64,6 +64,8 @@ export default function LeaderboardScores({ enabled: shouldFetch, }); + console.log(leaderboard); + /** * Starts the animation for the scores, but only after the initial load. */ @@ -118,6 +120,8 @@ export default function LeaderboardScores({ return; } + console.log(selectedLeaderboardId); + // Update the URL window.history.replaceState(null, "", `/leaderboard/${selectedLeaderboardId}/${currentPage}`); }, [selectedLeaderboardId, currentPage, disableUrlChanging]); @@ -157,7 +161,7 @@ export default function LeaderboardScores({ borderColor: getDifficulty(difficulty).color, }} > - {difficulty} + {difficulty.replace("Plus", "+")} ); })}