integration tests
Some checks failed
CI / lint-typecheck (pull_request) Failing after 4m51s
CI / tests (pull_request) Has been skipped
CI / contract-tests (pull_request) Has been skipped
CI / e2e-tests (pull_request) Has been skipped
CI / comment-pr (pull_request) Has been skipped
CI / commit-types (pull_request) Has been skipped

This commit is contained in:
2026-01-24 01:13:49 +01:00
parent 9bb6b228f1
commit 9ccecbf3bb
25 changed files with 895 additions and 2688 deletions

View File

@@ -0,0 +1,55 @@
/**
* Rating Entity
*
* Represents a driver's rating calculated after a race.
*/
import { DriverId } from '../../racing/domain/entities/DriverId';
import { RaceId } from '../../racing/domain/entities/RaceId';
import { RatingComponents } from './RatingComponents';
export interface RatingProps {
driverId: DriverId;
raceId: RaceId;
rating: number;
components: RatingComponents;
timestamp: Date;
}
export class Rating {
private constructor(private readonly props: RatingProps) {}
static create(props: RatingProps): Rating {
return new Rating(props);
}
get driverId(): DriverId {
return this.props.driverId;
}
get raceId(): RaceId {
return this.props.raceId;
}
get rating(): number {
return this.props.rating;
}
get components(): RatingComponents {
return this.props.components;
}
get timestamp(): Date {
return this.props.timestamp;
}
toJSON(): Record<string, any> {
return {
driverId: this.driverId.toString(),
raceId: this.raceId.toString(),
rating: this.rating,
components: this.components,
timestamp: this.timestamp.toISOString(),
};
}
}

View File

@@ -0,0 +1,14 @@
/**
* RatingComponents
*
* Represents the individual components that make up a driver's rating.
*/
export interface RatingComponents {
resultsStrength: number;
consistency: number;
cleanDriving: number;
racecraft: number;
reliability: number;
teamContribution: number;
}

View File

@@ -0,0 +1,29 @@
/**
* RatingCalculatedEvent
*
* Event published when a driver's rating is calculated.
*/
import { DomainEvent } from '../../../shared/ports/EventPublisher';
import { Rating } from '../Rating';
export class RatingCalculatedEvent implements DomainEvent {
readonly type = 'RatingCalculatedEvent';
readonly timestamp: Date;
constructor(private readonly rating: Rating) {
this.timestamp = new Date();
}
getRating(): Rating {
return this.rating;
}
toJSON(): Record<string, any> {
return {
type: this.type,
timestamp: this.timestamp.toISOString(),
rating: this.rating.toJSON(),
};
}
}