force track players bc it never ran
All checks were successful
Deploy Backend / deploy (push) Successful in 3m2s

This commit is contained in:
Lee 2024-10-10 01:15:16 +01:00
parent 82116a7405
commit d5cc35da05
2 changed files with 16 additions and 5 deletions

View File

@ -99,6 +99,11 @@ app.use(
})
);
/**
* Start cronjobs
*/
PlayerService.initCronjobs();
/**
* Swagger Documentation
*/
@ -108,9 +113,4 @@ app.onStart(() => {
console.log("Listening on port http://localhost:8080");
});
/**
* Start cronjobs
*/
PlayerService.initCronjobs();
app.listen(8080);

View File

@ -12,15 +12,26 @@ export class PlayerService {
* Initialize the cron jobs
*/
public static initCronjobs() {
(async () => {
console.log("Tracking player statistics...");
const players: PlayerDocument[] = await PlayerModel.find({});
for (const player of players) {
await PlayerService.trackScoreSaberPlayer(getMidnightAlignedDate(new Date()), player);
}
console.log("Finished tracking player statistics.");
})();
app.use(
cron({
name: "player-statistics-tracker-cron",
pattern: "0 1 * * *", // Every day at 00:01 (midnight)
run: async () => {
console.log("Tracking player statistics...");
const players: PlayerDocument[] = await PlayerModel.find({});
for (const player of players) {
await PlayerService.trackScoreSaberPlayer(getMidnightAlignedDate(new Date()), player);
}
console.log("Finished tracking player statistics.");
},
})
);