always ensure the frontpage of players is being tracked
All checks were successful
Deploy Backend / deploy (push) Successful in 3m19s

This commit is contained in:
Lee 2024-10-11 03:47:54 +01:00
parent 0e4feb4181
commit b059ee3537
3 changed files with 16 additions and 3 deletions

@ -7,4 +7,4 @@ export class NotFoundError extends Error {
) {
super(message);
}
}
}

@ -7,4 +7,4 @@ export class RateLimitError extends Error {
) {
super(message);
}
}
}

@ -16,7 +16,7 @@ import PlayerController from "./controller/player.controller";
import { PlayerService } from "./service/player.service";
import { cron } from "@elysiajs/cron";
import { PlayerDocument, PlayerModel } from "./model/player";
import { getMidnightAlignedDate } from "@ssr/common/utils/time-utils";
import { scoresaberService } from "@ssr/common/service/impl/scoresaber";
// Load .env file
dotenv.config({
@ -35,6 +35,19 @@ app.use(
pattern: "1 0 * * *", // Every day at 00:01 (London time)
timezone: "Europe/London",
run: async () => {
console.log("Fetching first page of players from ScoreSaber...");
const page = await scoresaberService.lookupPlayers(1);
if (page === undefined) {
console.log("Failed to fetch players from ScoreSaber");
return;
}
for (const player of page.players) {
await PlayerService.getPlayer(player.id, true);
}
console.log("All players on the front page are now being tracked :)");
// ---
console.log("Tracking player statistics...");
const players: PlayerDocument[] = await PlayerModel.find({});
for (const player of players) {