This commit is contained in:
parent
a3392ca468
commit
53b51582b2
@ -23,6 +23,7 @@ export async function GET(request: NextRequest) {
|
||||
if (shouldCreatePlayer && foundPlayer == null) {
|
||||
foundPlayer = await PlayerModel.create({
|
||||
_id: id,
|
||||
trackedSince: new Date(),
|
||||
});
|
||||
const response = await scoresaberService.lookupPlayer(id, true);
|
||||
if (response != undefined) {
|
||||
|
@ -14,7 +14,12 @@ export async function GET(request: NextRequest) {
|
||||
|
||||
// Fetch the player and return their statistic history
|
||||
let foundPlayer: IPlayer | null = await PlayerModel.findById(id);
|
||||
return NextResponse.json({
|
||||
|
||||
const response: { tracked: boolean; lastTracked?: string } = {
|
||||
tracked: foundPlayer != null,
|
||||
});
|
||||
};
|
||||
if (foundPlayer != null) {
|
||||
response["lastTracked"] = foundPlayer.trackedSince?.toUTCString();
|
||||
}
|
||||
return NextResponse.json(response);
|
||||
}
|
||||
|
@ -25,6 +25,11 @@ export interface IPlayer extends Document {
|
||||
*/
|
||||
rawPlayer: ScoreSaberPlayer;
|
||||
|
||||
/**
|
||||
* The first time the player was tracked
|
||||
*/
|
||||
trackedSince: Date;
|
||||
|
||||
/**
|
||||
* Gets when this player was last tracked.
|
||||
*/
|
||||
@ -62,6 +67,7 @@ const PlayerSchema = new Schema<IPlayer>({
|
||||
lastTracked: { type: Date, default: new Date(), required: false },
|
||||
rawPlayer: { type: Object, required: false },
|
||||
statisticHistory: { type: Map, default: () => new Map(), required: false },
|
||||
trackedSince: { type: Date, default: new Date(), required: false },
|
||||
});
|
||||
|
||||
PlayerSchema.methods.getLastTracked = function (): Date {
|
||||
|
Reference in New Issue
Block a user