fix player data tracking
All checks were successful
Deploy Backend / docker (ubuntu-latest) (push) Successful in 40s

This commit is contained in:
Lee 2024-10-28 14:00:12 +00:00
parent df297d0c99
commit ad568ddf5d
2 changed files with 28 additions and 25 deletions

@ -61,19 +61,18 @@ connectBeatLeaderWebsocket({
}); });
export const app = new Elysia(); export const app = new Elysia();
if (isProduction()) { app.use(
app.use(
cron({ cron({
name: "player-statistics-tracker-cron", name: "player-statistics-tracker-cron",
pattern: "1 0 * * *", // Every day at 00:01 pattern: "0 1 * * * *", // Every day at 00:01
timezone: "Europe/London", // UTC time timezone: "Europe/London", // UTC time
protect: true, protect: true,
run: async () => { run: async () => {
await PlayerService.updatePlayerStatistics(); await PlayerService.updatePlayerStatistics();
}, },
}) })
); );
app.use( app.use(
cron({ cron({
name: "player-scores-tracker-cron", name: "player-scores-tracker-cron",
pattern: "0 4 * * *", // Every day at 04:00 pattern: "0 4 * * *", // Every day at 04:00
@ -83,8 +82,7 @@ if (isProduction()) {
await PlayerService.refreshPlayerScores(); await PlayerService.refreshPlayerScores();
}, },
}) })
); );
}
/** /**
* Custom error handler * Custom error handler

@ -174,7 +174,12 @@ export class ScoreService {
leaderboardToken: ScoreSaberLeaderboardToken, leaderboardToken: ScoreSaberLeaderboardToken,
playerId?: string playerId?: string
) { ) {
playerId = scoreToken.leaderboardPlayerInfo && (playerId || scoreToken.leaderboardPlayerInfo.id); playerId = (scoreToken.leaderboardPlayerInfo && scoreToken.leaderboardPlayerInfo.id) || playerId;
if (!playerId) {
console.error(`Player ID is undefined, unable to track score: ${scoreToken.id}`);
return;
}
const playerName = (scoreToken.leaderboardPlayerInfo && scoreToken.leaderboardPlayerInfo.name) || "Unknown"; const playerName = (scoreToken.leaderboardPlayerInfo && scoreToken.leaderboardPlayerInfo.name) || "Unknown";
const leaderboard = getScoreSaberLeaderboardFromToken(leaderboardToken); const leaderboard = getScoreSaberLeaderboardFromToken(leaderboardToken);