diff --git a/projects/backend/src/index.ts b/projects/backend/src/index.ts index 66e9659..e3644ca 100644 --- a/projects/backend/src/index.ts +++ b/projects/backend/src/index.ts @@ -61,30 +61,28 @@ connectBeatLeaderWebsocket({ }); export const app = new Elysia(); -if (isProduction()) { - app.use( - cron({ - name: "player-statistics-tracker-cron", - pattern: "1 0 * * *", // Every day at 00:01 - timezone: "Europe/London", // UTC time - protect: true, - run: async () => { - await PlayerService.updatePlayerStatistics(); - }, - }) - ); - app.use( - cron({ - name: "player-scores-tracker-cron", - pattern: "0 4 * * *", // Every day at 04:00 - timezone: "Europe/London", // UTC time - protect: true, - run: async () => { - await PlayerService.refreshPlayerScores(); - }, - }) - ); -} +app.use( + cron({ + name: "player-statistics-tracker-cron", + pattern: "0 1 * * * *", // Every day at 00:01 + timezone: "Europe/London", // UTC time + protect: true, + run: async () => { + await PlayerService.updatePlayerStatistics(); + }, + }) +); +app.use( + cron({ + name: "player-scores-tracker-cron", + pattern: "0 4 * * *", // Every day at 04:00 + timezone: "Europe/London", // UTC time + protect: true, + run: async () => { + await PlayerService.refreshPlayerScores(); + }, + }) +); /** * Custom error handler diff --git a/projects/backend/src/service/score.service.ts b/projects/backend/src/service/score.service.ts index 16cbadd..0590441 100644 --- a/projects/backend/src/service/score.service.ts +++ b/projects/backend/src/service/score.service.ts @@ -174,7 +174,12 @@ export class ScoreService { leaderboardToken: ScoreSaberLeaderboardToken, 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 leaderboard = getScoreSaberLeaderboardFromToken(leaderboardToken);