harden business rules

This commit is contained in:
2025-12-27 19:18:54 +01:00
parent 0e7a01d81c
commit 8d2b17d9a8
11 changed files with 343 additions and 55 deletions

View File

@@ -52,6 +52,7 @@ export class RacingLeagueFactory {
};
createdAt: Date;
socialLinks?: { discordUrl?: string; youtubeUrl?: string; websiteUrl?: string };
participantCount?: number;
} = {
id: `league-${i}`,
name: faker.company.name() + ' Racing League',
@@ -59,6 +60,8 @@ export class RacingLeagueFactory {
ownerId: owner.id.toString(),
settings: config,
createdAt,
// Start with some participants for ranked leagues to meet minimum requirements
participantCount: i % 3 === 0 ? 12 : i % 3 === 1 ? 8 : 0,
};
// Add social links with varying completeness

View File

@@ -65,8 +65,9 @@ export class RacingRaceFactory {
Race.create({
...base,
status: 'running',
strengthOfField: 1400 + (i * 10), // Varying SOF
strengthOfField: 45 + (i % 50), // Valid SOF: 0-100
registeredCount: 12 + (i % 5), // Varying registration counts
maxParticipants: 24, // Ensure max is set
}),
);
continue;
@@ -78,8 +79,9 @@ export class RacingRaceFactory {
Race.create({
...base,
status: 'completed',
strengthOfField: 1200 + (i * 15),
strengthOfField: 35 + (i % 60), // Valid SOF: 0-100
registeredCount: 8 + (i % 8),
maxParticipants: 20, // Ensure max is set
}),
);
continue;
@@ -93,8 +95,9 @@ export class RacingRaceFactory {
...base,
status: 'scheduled',
...(hasRegistrations && {
strengthOfField: 1300 + (i * 8),
strengthOfField: 40 + (i % 55), // Valid SOF: 0-100
registeredCount: 5 + (i % 10),
maxParticipants: 16 + (i % 10), // Ensure max is set and reasonable
}),
}),
);