team rating

This commit is contained in:
2025-12-30 12:25:45 +01:00
parent ccaa39c39c
commit 83371ea839
93 changed files with 10324 additions and 490 deletions

View File

@@ -19,39 +19,35 @@ export class RacingRaceFactory {
const races: Race[] = [];
// Create races with systematic coverage of different statuses and scenarios
const statuses: Array<'scheduled' | 'running' | 'completed' | 'cancelled'> = ['scheduled', 'running', 'completed', 'cancelled'];
for (let i = 1; i <= 100; i++) {
for (let i = 1; i <= 500; i++) {
const leagueId = leagueIds[(i - 1) % leagueIds.length] ?? demoLeagueId;
const trackId = trackIds[(i - 1) % trackIds.length]!;
const track = tracks.find(t => t.id === trackId)!;
// Determine status systematically to ensure coverage
// Determine status systematically to ensure good coverage
let status: 'scheduled' | 'running' | 'completed' | 'cancelled';
let scheduledAt: Date;
if (i <= 4) {
// First 4 races: one of each status
status = statuses[i - 1]!;
scheduledAt = this.addDays(this.baseDate, i <= 2 ? -35 + i : 1 + (i - 2) * 2);
} else if (i <= 10) {
// Next 6: completed races
status = 'completed';
scheduledAt = this.addDays(this.baseDate, -35 + i);
} else if (i <= 15) {
// Next 5: scheduled future races
status = 'scheduled';
scheduledAt = this.addDays(this.baseDate, 1 + (i - 10) * 3);
} else if (i <= 20) {
// Next 5: cancelled races
// Use modulo to create a balanced distribution across 500 races
const statusMod = i % 20; // 20 different patterns
if (statusMod === 1 || statusMod === 2 || statusMod === 3) {
// 15% running (3 out of 20)
status = 'running';
scheduledAt = this.addDays(this.baseDate, -1 + (statusMod * 0.5)); // Recent past/current
} else if (statusMod === 4 || statusMod === 5 || statusMod === 6 || statusMod === 7) {
// 20% cancelled (4 out of 20)
status = 'cancelled';
scheduledAt = this.addDays(this.baseDate, -20 + (i - 15));
scheduledAt = this.addDays(this.baseDate, -30 + (statusMod * 2));
} else if (statusMod === 8 || statusMod === 9 || statusMod === 10 || statusMod === 11 || statusMod === 12) {
// 25% completed (5 out of 20)
status = 'completed';
scheduledAt = this.addDays(this.baseDate, -50 + (statusMod * 3));
} else {
// Rest: mix of scheduled and completed
status = i % 3 === 0 ? 'completed' : 'scheduled';
scheduledAt = status === 'completed'
? this.addDays(this.baseDate, -10 + (i - 20))
: this.addDays(this.baseDate, 5 + (i - 20) * 2);
// 40% scheduled (8 out of 20)
status = 'scheduled';
scheduledAt = this.addDays(this.baseDate, 1 + ((statusMod - 13) * 2));
}
const base = {
@@ -63,58 +59,48 @@ export class RacingRaceFactory {
car: cars[(i - 1) % cars.length]!,
};
// Special case for running race
// Create race based on status with appropriate data
if (status === 'running') {
races.push(
Race.create({
...base,
status: 'running',
strengthOfField: 45 + (i % 50), // Valid SOF: 0-100
registeredCount: 12 + (i % 5), // Varying registration counts
maxParticipants: 24, // Ensure max is set
strengthOfField: 40 + (i % 60), // Valid SOF: 0-100
registeredCount: 10 + (i % 15), // Varying registration counts
maxParticipants: 20 + (i % 8), // 20-28 participants
}),
);
continue;
}
// Add varying SOF and registration counts for completed races
if (status === 'completed') {
} else if (status === 'completed') {
races.push(
Race.create({
...base,
status: 'completed',
strengthOfField: 35 + (i % 60), // Valid SOF: 0-100
registeredCount: 8 + (i % 8),
maxParticipants: 20, // Ensure max is set
strengthOfField: 30 + (i % 70), // Valid SOF: 0-100
registeredCount: 6 + (i % 12),
maxParticipants: 16 + (i % 10),
}),
);
continue;
}
// Scheduled races with some having registration data
if (status === 'scheduled') {
const hasRegistrations = i % 4 !== 0; // 75% have registrations
} else if (status === 'scheduled') {
const hasRegistrations = i % 3 !== 0; // 66% have registrations
races.push(
Race.create({
...base,
status: 'scheduled',
...(hasRegistrations && {
strengthOfField: 40 + (i % 55), // Valid SOF: 0-100
registeredCount: 5 + (i % 10),
maxParticipants: 16 + (i % 10), // Ensure max is set and reasonable
strengthOfField: 35 + (i % 65), // Valid SOF: 0-100
registeredCount: 4 + (i % 12),
maxParticipants: 14 + (i % 12),
}),
}),
);
continue;
} else if (status === 'cancelled') {
races.push(
Race.create({
...base,
status: 'cancelled',
}),
);
}
// Cancelled races
races.push(
Race.create({
...base,
status: 'cancelled',
}),
);
}
return races;