inmemory to postgres

This commit is contained in:
2025-12-29 18:34:12 +01:00
parent 9e17d0752a
commit f5639a367f
176 changed files with 10175 additions and 468 deletions

View File

@@ -116,6 +116,61 @@ export class Protest implements IEntity<string> {
return new Protest(protestProps);
}
static rehydrate(props: {
id: string;
raceId: string;
protestingDriverId: string;
accusedDriverId: string;
incident: { lap: number; description: string; timeInRace?: number };
comment?: string;
proofVideoUrl?: string;
status: string;
reviewedBy?: string;
decisionNotes?: string;
filedAt: Date;
reviewedAt?: Date;
defense?: { statement: string; videoUrl?: string; submittedAt: Date };
defenseRequestedAt?: Date;
defenseRequestedBy?: string;
}): Protest {
const id = ProtestId.create(props.id);
const raceId = RaceId.create(props.raceId);
const protestingDriverId = DriverId.create(props.protestingDriverId);
const accusedDriverId = DriverId.create(props.accusedDriverId);
const incident = ProtestIncident.create(props.incident.lap, props.incident.description, props.incident.timeInRace);
const comment = props.comment ? ProtestComment.create(props.comment) : undefined;
const proofVideoUrl = props.proofVideoUrl ? VideoUrl.create(props.proofVideoUrl) : undefined;
const status = ProtestStatus.create(props.status);
const reviewedBy = props.reviewedBy ? StewardId.create(props.reviewedBy) : undefined;
const decisionNotes = props.decisionNotes ? DecisionNotes.create(props.decisionNotes) : undefined;
const filedAt = FiledAt.create(props.filedAt);
const reviewedAt = props.reviewedAt ? ReviewedAt.create(props.reviewedAt) : undefined;
const defense = props.defense ? ProtestDefense.create(props.defense.statement, props.defense.submittedAt, props.defense.videoUrl) : undefined;
const defenseRequestedAt = props.defenseRequestedAt ? DefenseRequestedAt.create(props.defenseRequestedAt) : undefined;
const defenseRequestedBy = props.defenseRequestedBy ? StewardId.create(props.defenseRequestedBy) : undefined;
const protestProps: ProtestProps = {
id,
raceId,
protestingDriverId,
accusedDriverId,
incident,
status,
filedAt,
};
if (comment !== undefined) protestProps.comment = comment;
if (proofVideoUrl !== undefined) protestProps.proofVideoUrl = proofVideoUrl;
if (reviewedBy !== undefined) protestProps.reviewedBy = reviewedBy;
if (decisionNotes !== undefined) protestProps.decisionNotes = decisionNotes;
if (reviewedAt !== undefined) protestProps.reviewedAt = reviewedAt;
if (defense !== undefined) protestProps.defense = defense;
if (defenseRequestedAt !== undefined) protestProps.defenseRequestedAt = defenseRequestedAt;
if (defenseRequestedBy !== undefined) protestProps.defenseRequestedBy = defenseRequestedBy;
return new Protest(protestProps);
}
get id(): string { return this.props.id.toString(); }
get raceId(): string { return this.props.raceId.toString(); }
get protestingDriverId(): string { return this.props.protestingDriverId.toString(); }