add player tracked since date
All checks were successful
Deploy Backend / deploy (push) Successful in 3m6s
All checks were successful
Deploy Backend / deploy (push) Successful in 3m6s
This commit is contained in:
parent
6b8244fa48
commit
ee042fe91e
10
projects/backend/src/error/internal-server-error.ts
Normal file
10
projects/backend/src/error/internal-server-error.ts
Normal file
@ -0,0 +1,10 @@
|
||||
import { HttpCode } from "../common/http-codes";
|
||||
|
||||
export class InternalServerError extends Error {
|
||||
constructor(
|
||||
public message: string = "internal-server-error",
|
||||
public status: number = HttpCode.INTERNAL_SERVER_ERROR.code
|
||||
) {
|
||||
super(message);
|
||||
}
|
||||
}
|
@ -20,9 +20,18 @@ export class Player {
|
||||
@prop()
|
||||
private statisticHistory?: Record<string, PlayerHistory>;
|
||||
|
||||
/**
|
||||
* The date the player was last tracked.
|
||||
*/
|
||||
@prop()
|
||||
public lastTracked?: Date;
|
||||
|
||||
/**
|
||||
* The date the player was first tracked.
|
||||
*/
|
||||
@prop()
|
||||
public trackedSince?: Date;
|
||||
|
||||
/**
|
||||
* Gets the player's statistic history.
|
||||
*/
|
||||
|
@ -5,6 +5,7 @@ import { app } from "../index";
|
||||
import { getDaysAgoDate, getMidnightAlignedDate } from "@ssr/common/utils/time-utils";
|
||||
import { scoresaberService } from "@ssr/common/service/impl/scoresaber";
|
||||
import ScoreSaberPlayerToken from "@ssr/common/types/token/scoresaber/score-saber-player-token";
|
||||
import { InternalServerError } from "../error/internal-server-error";
|
||||
|
||||
export class PlayerService {
|
||||
/**
|
||||
@ -49,8 +50,9 @@ export class PlayerService {
|
||||
console.log(`Creating player "${id}"...`);
|
||||
player = (await PlayerModel.create({ _id: id })) as any;
|
||||
if (player === null) {
|
||||
throw new NotFoundError(`Player "${id}" not found`);
|
||||
throw new InternalServerError(`Failed to create player document for "${id}"`);
|
||||
}
|
||||
player.trackedSince = new Date();
|
||||
await this.seedPlayerHistory(player, playerToken);
|
||||
console.log(`Created player "${id}".`);
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user