seed data
This commit is contained in:
29
adapters/bootstrap/racing/RacingDriverFactory.ts
Normal file
29
adapters/bootstrap/racing/RacingDriverFactory.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import { Driver } from '@core/racing/domain/entities/Driver';
|
||||
|
||||
export class RacingDriverFactory {
|
||||
constructor(
|
||||
private readonly driverCount: number,
|
||||
private readonly baseDate: Date,
|
||||
) {}
|
||||
|
||||
create(): Driver[] {
|
||||
const countries = ['DE', 'NL', 'FR', 'GB', 'US', 'CA', 'SE', 'NO', 'IT', 'ES'] as const;
|
||||
|
||||
return Array.from({ length: this.driverCount }, (_, idx) => {
|
||||
const i = idx + 1;
|
||||
|
||||
return Driver.create({
|
||||
id: `driver-${i}`,
|
||||
iracingId: String(100000 + i),
|
||||
name: `Driver ${i}`,
|
||||
country: countries[idx % countries.length]!,
|
||||
bio: `Demo driver #${i} seeded for in-memory mode.`,
|
||||
joinedAt: this.addDays(this.baseDate, -90 + i),
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private addDays(date: Date, days: number): Date {
|
||||
return new Date(date.getTime() + days * 24 * 60 * 60 * 1000);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user