more seeds

This commit is contained in:
2025-12-27 02:00:17 +01:00
parent 15435c93fc
commit 58d9a1c762
4 changed files with 258 additions and 38 deletions

View File

@@ -10,16 +10,28 @@ export class RacingLeagueFactory {
create(): League[] {
const leagueCount = 20;
const pointsSystems = ['f1-2024', 'indycar', 'custom'] as const;
const qualifyingFormats = ['open', 'single-lap'] as const;
// Create diverse league configurations
const leagueConfigs = [
// Small sprint leagues
{ maxDrivers: 16, sessionDuration: 30, pointsSystem: 'f1-2024' as const, qualifyingFormat: 'single-lap' as const },
{ maxDrivers: 20, sessionDuration: 45, pointsSystem: 'f1-2024' as const, qualifyingFormat: 'open' as const },
// Medium endurance leagues
{ maxDrivers: 24, sessionDuration: 60, pointsSystem: 'indycar' as const, qualifyingFormat: 'open' as const },
{ maxDrivers: 28, sessionDuration: 90, pointsSystem: 'custom' as const, qualifyingFormat: 'open' as const },
// Large mixed leagues
{ maxDrivers: 32, sessionDuration: 120, pointsSystem: 'f1-2024' as const, qualifyingFormat: 'open' as const },
{ maxDrivers: 36, sessionDuration: 75, pointsSystem: 'indycar' as const, qualifyingFormat: 'single-lap' as const },
{ maxDrivers: 40, sessionDuration: 100, pointsSystem: 'custom' as const, qualifyingFormat: 'open' as const },
{ maxDrivers: 44, sessionDuration: 85, pointsSystem: 'f1-2024' as const, qualifyingFormat: 'open' as const },
{ maxDrivers: 48, sessionDuration: 110, pointsSystem: 'indycar' as const, qualifyingFormat: 'single-lap' as const },
{ maxDrivers: 50, sessionDuration: 95, pointsSystem: 'custom' as const, qualifyingFormat: 'open' as const },
];
return Array.from({ length: leagueCount }, (_, idx) => {
const i = idx + 1;
const owner = faker.helpers.arrayElement(this.drivers);
const socialLinks: { discordUrl?: string; youtubeUrl?: string; websiteUrl?: string } = {};
if (faker.datatype.boolean()) socialLinks.discordUrl = faker.internet.url();
if (faker.datatype.boolean()) socialLinks.youtubeUrl = faker.internet.url();
if (faker.datatype.boolean()) socialLinks.websiteUrl = faker.internet.url();
const config = leagueConfigs[idx % leagueConfigs.length]!;
const leagueData: {
id: string;
@@ -39,15 +51,24 @@ export class RacingLeagueFactory {
name: faker.company.name() + ' Racing League',
description: faker.lorem.sentences(2),
ownerId: owner.id.toString(),
settings: {
pointsSystem: faker.helpers.arrayElement(pointsSystems),
maxDrivers: faker.number.int({ min: 20, max: 50 }),
sessionDuration: faker.number.int({ min: 30, max: 180 }),
qualifyingFormat: faker.helpers.arrayElement(qualifyingFormats),
},
settings: config,
createdAt: faker.date.past({ years: 2, refDate: this.baseDate }),
};
// Add social links with varying completeness
const socialLinks: { discordUrl?: string; youtubeUrl?: string; websiteUrl?: string } = {};
const socialLinkTypes = ['discord', 'youtube', 'website'] as const;
// Ensure some leagues have no social links, some have partial, some have all
const numSocialLinks = idx % 4; // 0, 1, 2, or 3
const selectedTypes = faker.helpers.arrayElements(socialLinkTypes, numSocialLinks);
selectedTypes.forEach(type => {
if (type === 'discord') socialLinks.discordUrl = faker.internet.url();
if (type === 'youtube') socialLinks.youtubeUrl = faker.internet.url();
if (type === 'website') socialLinks.websiteUrl = faker.internet.url();
});
if (Object.keys(socialLinks).length > 0) {
leagueData.socialLinks = socialLinks;
}