fix leaderboard id
This commit is contained in:
parent
96ab9be79a
commit
d086e922c4
@ -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;
|
||||
}
|
||||
|
@ -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<typeof ScoreSaberLeaderboardInternal>;
|
||||
export type ScoreSaberLeaderboardDocument = ScoreSaberLeaderboard & Document;
|
||||
export const ScoreSaberLeaderboardModel: ReturnModelType<typeof ScoreSaberLeaderboard> =
|
||||
getModelForClass(ScoreSaberLeaderboard);
|
||||
export const ScoreSaberLeaderboardModel: ReturnModelType<typeof ScoreSaberLeaderboardInternal> =
|
||||
getModelForClass(ScoreSaberLeaderboardInternal);
|
||||
|
@ -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", "+")}
|
||||
</Button>
|
||||
);
|
||||
})}
|
||||
|
Reference in New Issue
Block a user