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 BeatSaverService from "./beatsaver.service";
|
||||||
import { BeatSaverMap } from "@ssr/common/model/beatsaver/map";
|
import { BeatSaverMap } from "@ssr/common/model/beatsaver/map";
|
||||||
import { getScoreSaberLeaderboardFromToken } from "@ssr/common/token-creators";
|
import { getScoreSaberLeaderboardFromToken } from "@ssr/common/token-creators";
|
||||||
import ScoreSaberLeaderboard, {
|
import {
|
||||||
|
ScoreSaberLeaderboard,
|
||||||
ScoreSaberLeaderboardModel,
|
ScoreSaberLeaderboardModel,
|
||||||
} from "@ssr/common/model/leaderboard/impl/scoresaber-leaderboard";
|
} from "@ssr/common/model/leaderboard/impl/scoresaber-leaderboard";
|
||||||
import Leaderboard from "@ssr/common/model/leaderboard/leaderboard";
|
import Leaderboard from "@ssr/common/model/leaderboard/leaderboard";
|
||||||
@ -46,11 +47,12 @@ export default class LeaderboardService {
|
|||||||
let foundLeaderboard = false;
|
let foundLeaderboard = false;
|
||||||
const cachedLeaderboard = await ScoreSaberLeaderboardModel.findById(id);
|
const cachedLeaderboard = await ScoreSaberLeaderboardModel.findById(id);
|
||||||
if (cachedLeaderboard != null) {
|
if (cachedLeaderboard != null) {
|
||||||
leaderboard = cachedLeaderboard as unknown as ScoreSaberLeaderboard;
|
leaderboard = cachedLeaderboard.toObject() as unknown as ScoreSaberLeaderboard;
|
||||||
if (
|
if (
|
||||||
leaderboard.ranked || // Never refresh ranked leaderboards (it will get refreshed every night)
|
leaderboard &&
|
||||||
|
(leaderboard.ranked || // Never refresh ranked leaderboards (it will get refreshed every night)
|
||||||
leaderboard.lastRefreshed == undefined || // Refresh if it has never been refreshed
|
leaderboard.lastRefreshed == undefined || // Refresh if it has never been refreshed
|
||||||
now.getTime() - leaderboard.lastRefreshed.getTime() > 1000 * 60 * 60 * 24 // Refresh every day
|
now.getTime() - leaderboard.lastRefreshed.getTime() > 1000 * 60 * 60 * 24) // Refresh every day
|
||||||
) {
|
) {
|
||||||
foundLeaderboard = true;
|
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.
|
* The star count for the leaderboard.
|
||||||
*/
|
*/
|
||||||
@ -50,6 +50,7 @@ export default class ScoreSaberLeaderboard extends Leaderboard {
|
|||||||
readonly status!: LeaderboardStatus;
|
readonly status!: LeaderboardStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type ScoreSaberLeaderboard = InstanceType<typeof ScoreSaberLeaderboardInternal>;
|
||||||
export type ScoreSaberLeaderboardDocument = ScoreSaberLeaderboard & Document;
|
export type ScoreSaberLeaderboardDocument = ScoreSaberLeaderboard & Document;
|
||||||
export const ScoreSaberLeaderboardModel: ReturnModelType<typeof ScoreSaberLeaderboard> =
|
export const ScoreSaberLeaderboardModel: ReturnModelType<typeof ScoreSaberLeaderboardInternal> =
|
||||||
getModelForClass(ScoreSaberLeaderboard);
|
getModelForClass(ScoreSaberLeaderboardInternal);
|
||||||
|
@ -64,6 +64,8 @@ export default function LeaderboardScores({
|
|||||||
enabled: shouldFetch,
|
enabled: shouldFetch,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
console.log(leaderboard);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Starts the animation for the scores, but only after the initial load.
|
* Starts the animation for the scores, but only after the initial load.
|
||||||
*/
|
*/
|
||||||
@ -118,6 +120,8 @@ export default function LeaderboardScores({
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log(selectedLeaderboardId);
|
||||||
|
|
||||||
// Update the URL
|
// Update the URL
|
||||||
window.history.replaceState(null, "", `/leaderboard/${selectedLeaderboardId}/${currentPage}`);
|
window.history.replaceState(null, "", `/leaderboard/${selectedLeaderboardId}/${currentPage}`);
|
||||||
}, [selectedLeaderboardId, currentPage, disableUrlChanging]);
|
}, [selectedLeaderboardId, currentPage, disableUrlChanging]);
|
||||||
@ -157,7 +161,7 @@ export default function LeaderboardScores({
|
|||||||
borderColor: getDifficulty(difficulty).color,
|
borderColor: getDifficulty(difficulty).color,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{difficulty}
|
{difficulty.replace("Plus", "+")}
|
||||||
</Button>
|
</Button>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
Reference in New Issue
Block a user