import type { DriverStats } from '@core/racing/domain/services/IDriverStatsService'; /** * Global store for driver stats that can be populated during seeding * and read by the InMemoryDriverStatsService */ export class DriverStatsStore { private static instance: DriverStatsStore; private statsMap = new Map(); private constructor() {} static getInstance(): DriverStatsStore { if (!DriverStatsStore.instance) { DriverStatsStore.instance = new DriverStatsStore(); } return DriverStatsStore.instance; } /** * Populate the store with stats (called during seeding) */ loadStats(stats: Map): void { this.statsMap.clear(); stats.forEach((input, driverId) => { this.statsMap.set(driverId, input); }); } /** * Get stats for a specific driver */ getDriverStats(driverId: string): DriverStats | null { return this.statsMap.get(driverId) ?? null; } /** * Clear all stats (useful for reseeding) */ clear(): void { this.statsMap.clear(); } /** * Get all stats (for debugging) */ getAllStats(): Map { return new Map(this.statsMap); } }