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

View File

@ -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

View File

@ -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);