seed data
This commit is contained in:
50
adapters/racing/services/TeamStatsStore.ts
Normal file
50
adapters/racing/services/TeamStatsStore.ts
Normal file
@@ -0,0 +1,50 @@
|
||||
import type { TeamStats } from '@adapters/bootstrap/racing/RacingTeamFactory';
|
||||
|
||||
/**
|
||||
* Global store for team stats that can be populated during seeding
|
||||
* and read by the AllTeamsPresenter
|
||||
*/
|
||||
export class TeamStatsStore {
|
||||
private static instance: TeamStatsStore;
|
||||
private statsMap = new Map<string, TeamStats>();
|
||||
|
||||
private constructor() {}
|
||||
|
||||
static getInstance(): TeamStatsStore {
|
||||
if (!TeamStatsStore.instance) {
|
||||
TeamStatsStore.instance = new TeamStatsStore();
|
||||
}
|
||||
return TeamStatsStore.instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Populate the store with stats (called during seeding)
|
||||
*/
|
||||
loadStats(stats: Map<string, TeamStats>): void {
|
||||
this.statsMap.clear();
|
||||
stats.forEach((input, teamId) => {
|
||||
this.statsMap.set(teamId, input);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get stats for a specific team
|
||||
*/
|
||||
getTeamStats(teamId: string): TeamStats | null {
|
||||
return this.statsMap.get(teamId) ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear all stats (useful for reseeding)
|
||||
*/
|
||||
clear(): void {
|
||||
this.statsMap.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all stats (for debugging)
|
||||
*/
|
||||
getAllStats(): Map<string, TeamStats> {
|
||||
return new Map(this.statsMap);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user