seed data
This commit is contained in:
@@ -20,6 +20,7 @@ export class Driver implements IEntity<string> {
|
||||
readonly country: CountryCode;
|
||||
readonly bio: DriverBio | undefined;
|
||||
readonly joinedAt: JoinedAt;
|
||||
readonly category: string | undefined;
|
||||
|
||||
private constructor(props: {
|
||||
id: string;
|
||||
@@ -28,6 +29,7 @@ export class Driver implements IEntity<string> {
|
||||
country: CountryCode;
|
||||
bio?: DriverBio;
|
||||
joinedAt: JoinedAt;
|
||||
category?: string;
|
||||
}) {
|
||||
this.id = props.id;
|
||||
this.iracingId = props.iracingId;
|
||||
@@ -35,6 +37,7 @@ export class Driver implements IEntity<string> {
|
||||
this.country = props.country;
|
||||
this.bio = props.bio;
|
||||
this.joinedAt = props.joinedAt;
|
||||
this.category = props.category;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -47,19 +50,36 @@ export class Driver implements IEntity<string> {
|
||||
country: string;
|
||||
bio?: string;
|
||||
joinedAt?: Date;
|
||||
category?: string;
|
||||
}): Driver {
|
||||
if (!props.id || props.id.trim().length === 0) {
|
||||
throw new RacingDomainValidationError('Driver ID is required');
|
||||
}
|
||||
|
||||
return new Driver({
|
||||
const driverProps: {
|
||||
id: string;
|
||||
iracingId: IRacingId;
|
||||
name: DriverName;
|
||||
country: CountryCode;
|
||||
bio?: DriverBio;
|
||||
joinedAt: JoinedAt;
|
||||
category?: string;
|
||||
} = {
|
||||
id: props.id,
|
||||
iracingId: IRacingId.create(props.iracingId),
|
||||
name: DriverName.create(props.name),
|
||||
country: CountryCode.create(props.country),
|
||||
...(props.bio !== undefined ? { bio: DriverBio.create(props.bio) } : {}),
|
||||
joinedAt: JoinedAt.create(props.joinedAt ?? new Date()),
|
||||
});
|
||||
};
|
||||
|
||||
if (props.bio !== undefined) {
|
||||
driverProps.bio = DriverBio.create(props.bio);
|
||||
}
|
||||
if (props.category !== undefined) {
|
||||
driverProps.category = props.category;
|
||||
}
|
||||
|
||||
return new Driver(driverProps);
|
||||
}
|
||||
|
||||
static rehydrate(props: {
|
||||
@@ -69,15 +89,32 @@ export class Driver implements IEntity<string> {
|
||||
country: string;
|
||||
bio?: string;
|
||||
joinedAt: Date;
|
||||
category?: string;
|
||||
}): Driver {
|
||||
return new Driver({
|
||||
const driverProps: {
|
||||
id: string;
|
||||
iracingId: IRacingId;
|
||||
name: DriverName;
|
||||
country: CountryCode;
|
||||
bio?: DriverBio;
|
||||
joinedAt: JoinedAt;
|
||||
category?: string;
|
||||
} = {
|
||||
id: props.id,
|
||||
iracingId: IRacingId.create(props.iracingId),
|
||||
name: DriverName.create(props.name),
|
||||
country: CountryCode.create(props.country),
|
||||
...(props.bio !== undefined ? { bio: DriverBio.create(props.bio) } : {}),
|
||||
joinedAt: JoinedAt.create(props.joinedAt),
|
||||
});
|
||||
};
|
||||
|
||||
if (props.bio !== undefined) {
|
||||
driverProps.bio = DriverBio.create(props.bio);
|
||||
}
|
||||
if (props.category !== undefined) {
|
||||
driverProps.category = props.category;
|
||||
}
|
||||
|
||||
return new Driver(driverProps);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -87,18 +124,36 @@ export class Driver implements IEntity<string> {
|
||||
name: string;
|
||||
country: string;
|
||||
bio: string | undefined;
|
||||
category: string | undefined;
|
||||
}>): Driver {
|
||||
const nextName = 'name' in props ? DriverName.create(props.name!) : this.name;
|
||||
const nextCountry = 'country' in props ? CountryCode.create(props.country!) : this.country;
|
||||
const nextBio = 'bio' in props ? (props.bio ? DriverBio.create(props.bio) : undefined) : this.bio;
|
||||
const nextCategory = 'category' in props ? props.category : this.category;
|
||||
|
||||
return new Driver({
|
||||
const driverProps: {
|
||||
id: string;
|
||||
iracingId: IRacingId;
|
||||
name: DriverName;
|
||||
country: CountryCode;
|
||||
bio?: DriverBio;
|
||||
joinedAt: JoinedAt;
|
||||
category?: string;
|
||||
} = {
|
||||
id: this.id,
|
||||
iracingId: this.iracingId,
|
||||
name: nextName,
|
||||
country: nextCountry,
|
||||
...(nextBio !== undefined ? { bio: nextBio } : {}),
|
||||
joinedAt: this.joinedAt,
|
||||
});
|
||||
};
|
||||
|
||||
if (nextBio !== undefined) {
|
||||
driverProps.bio = nextBio;
|
||||
}
|
||||
if (nextCategory !== undefined) {
|
||||
driverProps.category = nextCategory;
|
||||
}
|
||||
|
||||
return new Driver(driverProps);
|
||||
}
|
||||
}
|
||||
@@ -96,6 +96,7 @@ export class League implements IEntity<LeagueId> {
|
||||
readonly description: LeagueDescription;
|
||||
readonly ownerId: LeagueOwnerId;
|
||||
readonly settings: LeagueSettings;
|
||||
readonly category?: string | undefined;
|
||||
readonly createdAt: LeagueCreatedAt;
|
||||
readonly socialLinks: LeagueSocialLinks | undefined;
|
||||
|
||||
@@ -109,6 +110,7 @@ export class League implements IEntity<LeagueId> {
|
||||
description: LeagueDescription;
|
||||
ownerId: LeagueOwnerId;
|
||||
settings: LeagueSettings;
|
||||
category?: string | undefined;
|
||||
createdAt: LeagueCreatedAt;
|
||||
socialLinks?: LeagueSocialLinks;
|
||||
participantCount: ParticipantCount;
|
||||
@@ -119,6 +121,7 @@ export class League implements IEntity<LeagueId> {
|
||||
this.description = props.description;
|
||||
this.ownerId = props.ownerId;
|
||||
this.settings = props.settings;
|
||||
this.category = props.category;
|
||||
this.createdAt = props.createdAt;
|
||||
this.socialLinks = props.socialLinks;
|
||||
this._participantCount = props.participantCount;
|
||||
@@ -135,6 +138,7 @@ export class League implements IEntity<LeagueId> {
|
||||
description: string;
|
||||
ownerId: string;
|
||||
settings?: Partial<LeagueSettings>;
|
||||
category?: string | undefined;
|
||||
createdAt?: Date;
|
||||
socialLinks?: {
|
||||
discordUrl?: string;
|
||||
@@ -245,6 +249,7 @@ export class League implements IEntity<LeagueId> {
|
||||
description,
|
||||
ownerId,
|
||||
settings: finalSettings,
|
||||
category: props.category,
|
||||
createdAt,
|
||||
...(socialLinks !== undefined ? { socialLinks } : {}),
|
||||
participantCount,
|
||||
@@ -258,6 +263,7 @@ export class League implements IEntity<LeagueId> {
|
||||
description: string;
|
||||
ownerId: string;
|
||||
settings: LeagueSettings;
|
||||
category?: string | undefined;
|
||||
createdAt: Date;
|
||||
participantCount: number;
|
||||
socialLinks?: {
|
||||
@@ -286,6 +292,7 @@ export class League implements IEntity<LeagueId> {
|
||||
description,
|
||||
ownerId,
|
||||
settings: props.settings,
|
||||
category: props.category,
|
||||
createdAt,
|
||||
...(socialLinks !== undefined ? { socialLinks } : {}),
|
||||
participantCount,
|
||||
@@ -343,6 +350,7 @@ export class League implements IEntity<LeagueId> {
|
||||
description: string;
|
||||
ownerId: string;
|
||||
settings: LeagueSettings;
|
||||
category?: string | undefined;
|
||||
socialLinks?: {
|
||||
discordUrl?: string;
|
||||
youtubeUrl?: string;
|
||||
@@ -414,6 +422,7 @@ export class League implements IEntity<LeagueId> {
|
||||
description,
|
||||
ownerId,
|
||||
settings: newSettings,
|
||||
category: props.category ?? this.category,
|
||||
createdAt: this.createdAt,
|
||||
...(socialLinks !== undefined ? { socialLinks } : {}),
|
||||
participantCount: this._participantCount,
|
||||
@@ -447,6 +456,7 @@ export class League implements IEntity<LeagueId> {
|
||||
description: this.description,
|
||||
ownerId: this.ownerId,
|
||||
settings: this.settings,
|
||||
category: this.category,
|
||||
createdAt: this.createdAt,
|
||||
...(this.socialLinks !== undefined ? { socialLinks: this.socialLinks } : {}),
|
||||
participantCount: newCount,
|
||||
@@ -470,6 +480,7 @@ export class League implements IEntity<LeagueId> {
|
||||
description: this.description,
|
||||
ownerId: this.ownerId,
|
||||
settings: this.settings,
|
||||
category: this.category,
|
||||
createdAt: this.createdAt,
|
||||
...(this.socialLinks !== undefined ? { socialLinks: this.socialLinks } : {}),
|
||||
participantCount: newCount,
|
||||
|
||||
@@ -22,6 +22,8 @@ export class Team implements IEntity<string> {
|
||||
readonly description: TeamDescription;
|
||||
readonly ownerId: DriverId;
|
||||
readonly leagues: LeagueId[];
|
||||
readonly category: string | undefined;
|
||||
readonly isRecruiting: boolean;
|
||||
readonly createdAt: TeamCreatedAt;
|
||||
|
||||
private constructor(props: {
|
||||
@@ -31,6 +33,8 @@ export class Team implements IEntity<string> {
|
||||
description: TeamDescription;
|
||||
ownerId: DriverId;
|
||||
leagues: LeagueId[];
|
||||
category: string | undefined;
|
||||
isRecruiting: boolean;
|
||||
createdAt: TeamCreatedAt;
|
||||
}) {
|
||||
this.id = props.id;
|
||||
@@ -39,6 +43,8 @@ export class Team implements IEntity<string> {
|
||||
this.description = props.description;
|
||||
this.ownerId = props.ownerId;
|
||||
this.leagues = props.leagues;
|
||||
this.category = props.category;
|
||||
this.isRecruiting = props.isRecruiting;
|
||||
this.createdAt = props.createdAt;
|
||||
}
|
||||
|
||||
@@ -52,6 +58,8 @@ export class Team implements IEntity<string> {
|
||||
description: string;
|
||||
ownerId: string;
|
||||
leagues: string[];
|
||||
category?: string;
|
||||
isRecruiting?: boolean;
|
||||
createdAt?: Date;
|
||||
}): Team {
|
||||
if (!props.id || props.id.trim().length === 0) {
|
||||
@@ -69,6 +77,8 @@ export class Team implements IEntity<string> {
|
||||
description: TeamDescription.create(props.description),
|
||||
ownerId: DriverId.create(props.ownerId),
|
||||
leagues: props.leagues.map(leagueId => LeagueId.create(leagueId)),
|
||||
category: props.category,
|
||||
isRecruiting: props.isRecruiting ?? false,
|
||||
createdAt: TeamCreatedAt.create(props.createdAt ?? new Date()),
|
||||
});
|
||||
}
|
||||
@@ -80,6 +90,8 @@ export class Team implements IEntity<string> {
|
||||
description: string;
|
||||
ownerId: string;
|
||||
leagues: string[];
|
||||
category?: string;
|
||||
isRecruiting: boolean;
|
||||
createdAt: Date;
|
||||
}): Team {
|
||||
if (!props.id || props.id.trim().length === 0) {
|
||||
@@ -97,6 +109,8 @@ export class Team implements IEntity<string> {
|
||||
description: TeamDescription.create(props.description),
|
||||
ownerId: DriverId.create(props.ownerId),
|
||||
leagues: props.leagues.map(leagueId => LeagueId.create(leagueId)),
|
||||
category: props.category,
|
||||
isRecruiting: props.isRecruiting,
|
||||
createdAt: TeamCreatedAt.create(props.createdAt),
|
||||
});
|
||||
}
|
||||
@@ -110,12 +124,16 @@ export class Team implements IEntity<string> {
|
||||
description: string;
|
||||
ownerId: string;
|
||||
leagues: string[];
|
||||
category: string | undefined;
|
||||
isRecruiting: boolean;
|
||||
}>): Team {
|
||||
const nextName = 'name' in props ? TeamName.create(props.name!) : this.name;
|
||||
const nextTag = 'tag' in props ? TeamTag.create(props.tag!) : this.tag;
|
||||
const nextDescription = 'description' in props ? TeamDescription.create(props.description!) : this.description;
|
||||
const nextOwnerId = 'ownerId' in props ? DriverId.create(props.ownerId!) : this.ownerId;
|
||||
const nextLeagues = 'leagues' in props ? props.leagues!.map(leagueId => LeagueId.create(leagueId)) : this.leagues;
|
||||
const nextCategory = 'category' in props ? props.category : this.category;
|
||||
const nextIsRecruiting = 'isRecruiting' in props ? props.isRecruiting! : this.isRecruiting;
|
||||
|
||||
return new Team({
|
||||
id: this.id,
|
||||
@@ -124,6 +142,8 @@ export class Team implements IEntity<string> {
|
||||
description: nextDescription,
|
||||
ownerId: nextOwnerId,
|
||||
leagues: nextLeagues,
|
||||
category: nextCategory,
|
||||
isRecruiting: nextIsRecruiting,
|
||||
createdAt: this.createdAt,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ export interface TeamStats {
|
||||
totalWins: number;
|
||||
totalRaces: number;
|
||||
rating: number;
|
||||
category?: string;
|
||||
}
|
||||
|
||||
export interface ITeamStatsRepository {
|
||||
@@ -22,11 +23,6 @@ export interface ITeamStatsRepository {
|
||||
*/
|
||||
getTeamStats(teamId: string): Promise<TeamStats | null>;
|
||||
|
||||
/**
|
||||
* Get stats for a specific team (synchronous)
|
||||
*/
|
||||
getTeamStatsSync(teamId: string): TeamStats | null;
|
||||
|
||||
/**
|
||||
* Save stats for a specific team
|
||||
*/
|
||||
@@ -41,4 +37,4 @@ export interface ITeamStatsRepository {
|
||||
* Clear all stats
|
||||
*/
|
||||
clear(): Promise<void>;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user