some bug fixes and add the ranking page

This commit is contained in:
Lee
2024-10-11 02:43:28 +01:00
parent f649fb9c7f
commit e35c1c77d3
13 changed files with 345 additions and 18 deletions
projects
backend/src/service
common/src
website/src
app/(pages)
leaderboard/[...slug]
player/[...slug]
ranking/[[...slug]]
components
middleware.ts

@ -24,12 +24,15 @@ export class PlayerService {
}
console.log(`Creating player "${id}"...`);
player = (await PlayerModel.create({ _id: id })) as PlayerDocument;
if (player === null) {
throw new InternalServerError(`Failed to create player document for "${id}"`);
try {
player = (await PlayerModel.create({ _id: id })) as PlayerDocument;
player.trackedSince = new Date();
await this.seedPlayerHistory(player, playerToken);
} catch (err) {
const message = `Failed to create player document for "${id}"`;
console.log(message, err);
throw new InternalServerError(message);
}
player.trackedSince = new Date();
await this.seedPlayerHistory(player, playerToken);
}
return player;
}