seed data
This commit is contained in:
@@ -5,6 +5,17 @@ import type { TeamJoinRequest, TeamMembership } from '@core/racing/domain/types/
|
||||
import { faker } from '@faker-js/faker';
|
||||
import { seedId } from './SeedIdHelper';
|
||||
|
||||
export interface TeamStats {
|
||||
logoUrl: string;
|
||||
performanceLevel: 'beginner' | 'intermediate' | 'advanced' | 'pro';
|
||||
specialization: 'endurance' | 'sprint' | 'mixed';
|
||||
region: string;
|
||||
languages: string[];
|
||||
totalWins: number;
|
||||
totalRaces: number;
|
||||
rating: number;
|
||||
}
|
||||
|
||||
export class RacingTeamFactory {
|
||||
constructor(
|
||||
private readonly baseDate: Date,
|
||||
@@ -12,7 +23,7 @@ export class RacingTeamFactory {
|
||||
) {}
|
||||
|
||||
createTeams(drivers: Driver[], leagues: League[]): Team[] {
|
||||
const teamCount = 15;
|
||||
const teamCount = 50; // Increased from 15 to 50
|
||||
|
||||
return Array.from({ length: teamCount }, (_, idx) => {
|
||||
const i = idx + 1;
|
||||
@@ -177,8 +188,98 @@ export class RacingTeamFactory {
|
||||
return requests;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate team statistics and metadata for display
|
||||
* This would be stored in a separate stats table/service in production
|
||||
*/
|
||||
generateTeamStats(teams: Team[]): Map<string, TeamStats> {
|
||||
const statsMap = new Map<string, TeamStats>();
|
||||
|
||||
// Available logo URLs (simulating media uploads)
|
||||
const logoUrls = [
|
||||
'/images/ff1600.jpeg',
|
||||
'/images/header.jpeg',
|
||||
'/images/avatars/male-default-avatar.jpg',
|
||||
'/images/avatars/female-default-avatar.jpeg',
|
||||
'/images/avatars/neutral-default-avatar.jpeg',
|
||||
'/images/leagues/placeholder-cover.svg',
|
||||
];
|
||||
|
||||
// Available regions
|
||||
const regions = ['Europe', 'North America', 'South America', 'Asia', 'Oceania', 'Africa'];
|
||||
|
||||
// Available languages
|
||||
const allLanguages = ['English', 'German', 'French', 'Spanish', 'Italian', 'Portuguese', 'Japanese', 'Korean', 'Russian', 'Chinese'];
|
||||
|
||||
teams.forEach((team, idx) => {
|
||||
const i = idx + 1;
|
||||
|
||||
// Determine performance level based on index
|
||||
let performanceLevel: 'beginner' | 'intermediate' | 'advanced' | 'pro';
|
||||
let totalRaces: number;
|
||||
let rating: number;
|
||||
let totalWins: number;
|
||||
|
||||
if (i % 8 === 0) {
|
||||
// Pro teams
|
||||
performanceLevel = 'pro';
|
||||
totalRaces = faker.number.int({ min: 80, max: 150 });
|
||||
rating = faker.number.int({ min: 1700, max: 2000 });
|
||||
totalWins = faker.number.int({ min: 15, max: 40 });
|
||||
} else if (i % 5 === 0) {
|
||||
// Advanced teams
|
||||
performanceLevel = 'advanced';
|
||||
totalRaces = faker.number.int({ min: 40, max: 100 });
|
||||
rating = faker.number.int({ min: 1500, max: 1800 });
|
||||
totalWins = faker.number.int({ min: 8, max: 20 });
|
||||
} else if (i % 3 === 0) {
|
||||
// Intermediate teams
|
||||
performanceLevel = 'intermediate';
|
||||
totalRaces = faker.number.int({ min: 20, max: 60 });
|
||||
rating = faker.number.int({ min: 1200, max: 1600 });
|
||||
totalWins = faker.number.int({ min: 3, max: 12 });
|
||||
} else {
|
||||
// Beginner teams
|
||||
performanceLevel = 'beginner';
|
||||
totalRaces = faker.number.int({ min: 5, max: 25 });
|
||||
rating = faker.number.int({ min: 900, max: 1300 });
|
||||
totalWins = faker.number.int({ min: 0, max: 5 });
|
||||
}
|
||||
|
||||
// Determine specialization
|
||||
let specialization: 'endurance' | 'sprint' | 'mixed';
|
||||
if (i % 7 === 0) {
|
||||
specialization = 'endurance';
|
||||
} else if (i % 4 === 0) {
|
||||
specialization = 'sprint';
|
||||
} else {
|
||||
specialization = 'mixed';
|
||||
}
|
||||
|
||||
// Generate region and languages
|
||||
const region = faker.helpers.arrayElement(regions);
|
||||
const languageCount = faker.number.int({ min: 1, max: 3 });
|
||||
const languages = faker.helpers.arrayElements(allLanguages, languageCount);
|
||||
|
||||
// Generate logo URL (varied)
|
||||
const logoUrl = logoUrls[i % logoUrls.length] ?? logoUrls[0];
|
||||
|
||||
statsMap.set(team.id.toString(), {
|
||||
logoUrl: logoUrl!,
|
||||
performanceLevel,
|
||||
specialization,
|
||||
region,
|
||||
languages,
|
||||
totalWins,
|
||||
totalRaces,
|
||||
rating,
|
||||
});
|
||||
});
|
||||
|
||||
return statsMap;
|
||||
}
|
||||
|
||||
private addDays(date: Date, days: number): Date {
|
||||
return new Date(date.getTime() + days * 24 * 60 * 60 * 1000);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user