code quality
Some checks failed
CI / lint-typecheck (pull_request) Failing after 12s
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
Some checks failed
CI / lint-typecheck (pull_request) Failing after 12s
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:
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Rating Entity
|
||||
*
|
||||
*
|
||||
* Represents a driver's rating calculated after a race.
|
||||
*/
|
||||
|
||||
@@ -16,6 +16,14 @@ export interface RatingProps {
|
||||
timestamp: Date;
|
||||
}
|
||||
|
||||
export interface RatingJSON {
|
||||
driverId: string;
|
||||
raceId: string;
|
||||
rating: number;
|
||||
components: RatingComponents;
|
||||
timestamp: string;
|
||||
}
|
||||
|
||||
export class Rating {
|
||||
private constructor(private readonly props: RatingProps) {}
|
||||
|
||||
@@ -43,7 +51,7 @@ export class Rating {
|
||||
return this.props.timestamp;
|
||||
}
|
||||
|
||||
toJSON(): Record<string, any> {
|
||||
toJSON(): RatingJSON {
|
||||
return {
|
||||
driverId: this.driverId.toString(),
|
||||
raceId: this.raceId.toString(),
|
||||
|
||||
@@ -1,15 +1,22 @@
|
||||
/**
|
||||
* RatingCalculatedEvent
|
||||
*
|
||||
*
|
||||
* Event published when a driver's rating is calculated.
|
||||
*/
|
||||
|
||||
import { DomainEvent } from '../../../shared/ports/EventPublisher';
|
||||
import { Rating } from '../Rating';
|
||||
import { Rating, RatingJSON } from '../Rating';
|
||||
|
||||
export interface RatingCalculatedEventJSON {
|
||||
type: string;
|
||||
timestamp: string;
|
||||
rating: RatingJSON;
|
||||
}
|
||||
|
||||
export class RatingCalculatedEvent implements DomainEvent {
|
||||
readonly type = 'RatingCalculatedEvent';
|
||||
readonly timestamp: Date;
|
||||
[key: string]: unknown;
|
||||
|
||||
constructor(private readonly rating: Rating) {
|
||||
this.timestamp = new Date();
|
||||
@@ -19,7 +26,7 @@ export class RatingCalculatedEvent implements DomainEvent {
|
||||
return this.rating;
|
||||
}
|
||||
|
||||
toJSON(): Record<string, any> {
|
||||
toJSON(): RatingCalculatedEventJSON {
|
||||
return {
|
||||
type: this.type,
|
||||
timestamp: this.timestamp.toISOString(),
|
||||
|
||||
Reference in New Issue
Block a user