fix seeds

This commit is contained in:
2025-12-27 01:53:36 +01:00
parent 901fb1ac83
commit 15435c93fc
12 changed files with 259 additions and 200 deletions

View File

@@ -1,4 +1,5 @@
import { Driver } from '@core/racing/domain/entities/Driver';
import { faker } from '@faker-js/faker';
export class RacingDriverFactory {
constructor(
@@ -7,7 +8,7 @@ export class RacingDriverFactory {
) {}
create(): Driver[] {
const countries = ['DE', 'NL', 'FR', 'GB', 'US', 'CA', 'SE', 'NO', 'IT', 'ES'] as const;
const countries = ['DE', 'NL', 'FR', 'GB', 'US', 'CA', 'SE', 'NO', 'IT', 'ES', 'AU', 'BR', 'JP', 'KR', 'RU', 'PL', 'CZ', 'HU', 'AT', 'CH'] as const;
return Array.from({ length: this.driverCount }, (_, idx) => {
const i = idx + 1;
@@ -15,15 +16,11 @@ export class RacingDriverFactory {
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),
name: faker.person.fullName(),
country: faker.helpers.arrayElement(countries),
bio: faker.lorem.sentences(2),
joinedAt: faker.date.past({ years: 2, refDate: this.baseDate }),
});
});
}
private addDays(date: Date, days: number): Date {
return new Date(date.getTime() + days * 24 * 60 * 60 * 1000);
}
}