29 lines
1.1 KiB
TypeScript
29 lines
1.1 KiB
TypeScript
import type { Logger } from '@core/shared/application/Logger';
|
|
import type { ITeamStatsRepository, TeamStats } from '@core/racing/domain/repositories/ITeamStatsRepository';
|
|
|
|
export class InMemoryTeamStatsRepository implements ITeamStatsRepository {
|
|
private readonly stats = new Map<string, TeamStats>();
|
|
|
|
constructor(private readonly logger: Logger) {}
|
|
|
|
async getTeamStats(teamId: string): Promise<TeamStats | null> {
|
|
this.logger.debug(`[InMemoryTeamStatsRepository] Getting stats for team: ${teamId}`);
|
|
return this.stats.get(teamId) || null;
|
|
}
|
|
|
|
async saveTeamStats(teamId: string, stats: TeamStats): Promise<void> {
|
|
this.logger.debug(`[InMemoryTeamStatsRepository] Saving stats for team: ${teamId}`, stats);
|
|
this.stats.set(teamId, stats);
|
|
}
|
|
|
|
async getAllStats(): Promise<Map<string, TeamStats>> {
|
|
this.logger.debug('[InMemoryTeamStatsRepository] Getting all stats');
|
|
return new Map(this.stats);
|
|
}
|
|
|
|
async clear(): Promise<void> {
|
|
this.logger.debug('[InMemoryTeamStatsRepository] Clearing all stats');
|
|
this.stats.clear();
|
|
}
|
|
}
|