This commit is contained in:
2025-12-13 11:43:09 +01:00
parent 4b6fc668b5
commit bb0497f429
38 changed files with 3838 additions and 55 deletions

View File

@@ -0,0 +1,72 @@
/**
* In-memory implementation of IRaceEventRepository for development/testing.
*/
import type { IRaceEventRepository } from '../../domain/repositories/IRaceEventRepository';
import type { RaceEvent } from '../../domain/entities/RaceEvent';
export class InMemoryRaceEventRepository implements IRaceEventRepository {
private raceEvents: Map<string, RaceEvent> = new Map();
async findById(id: string): Promise<RaceEvent | null> {
return this.raceEvents.get(id) ?? null;
}
async findAll(): Promise<RaceEvent[]> {
return Array.from(this.raceEvents.values());
}
async findBySeasonId(seasonId: string): Promise<RaceEvent[]> {
return Array.from(this.raceEvents.values()).filter(
raceEvent => raceEvent.seasonId === seasonId
);
}
async findByLeagueId(leagueId: string): Promise<RaceEvent[]> {
return Array.from(this.raceEvents.values()).filter(
raceEvent => raceEvent.leagueId === leagueId
);
}
async findByStatus(status: string): Promise<RaceEvent[]> {
return Array.from(this.raceEvents.values()).filter(
raceEvent => raceEvent.status === status
);
}
async findAwaitingStewardingClose(): Promise<RaceEvent[]> {
const now = new Date();
return Array.from(this.raceEvents.values()).filter(
raceEvent =>
raceEvent.status === 'awaiting_stewarding' &&
raceEvent.stewardingClosesAt &&
raceEvent.stewardingClosesAt <= now
);
}
async create(raceEvent: RaceEvent): Promise<RaceEvent> {
this.raceEvents.set(raceEvent.id, raceEvent);
return raceEvent;
}
async update(raceEvent: RaceEvent): Promise<RaceEvent> {
this.raceEvents.set(raceEvent.id, raceEvent);
return raceEvent;
}
async delete(id: string): Promise<void> {
this.raceEvents.delete(id);
}
async exists(id: string): Promise<boolean> {
return this.raceEvents.has(id);
}
// Test helper methods
clear(): void {
this.raceEvents.clear();
}
getAll(): RaceEvent[] {
return Array.from(this.raceEvents.values());
}
}

View File

@@ -0,0 +1,62 @@
/**
* In-memory implementation of ISessionRepository for development/testing.
*/
import type { ISessionRepository } from '../../domain/repositories/ISessionRepository';
import type { Session } from '../../domain/entities/Session';
export class InMemorySessionRepository implements ISessionRepository {
private sessions: Map<string, Session> = new Map();
async findById(id: string): Promise<Session | null> {
return this.sessions.get(id) ?? null;
}
async findAll(): Promise<Session[]> {
return Array.from(this.sessions.values());
}
async findByRaceEventId(raceEventId: string): Promise<Session[]> {
return Array.from(this.sessions.values()).filter(
session => session.raceEventId === raceEventId
);
}
async findByLeagueId(leagueId: string): Promise<Session[]> {
// Sessions don't have leagueId directly - would need to join with RaceEvent
// For now, return empty array
return [];
}
async findByStatus(status: string): Promise<Session[]> {
return Array.from(this.sessions.values()).filter(
session => session.status === status
);
}
async create(session: Session): Promise<Session> {
this.sessions.set(session.id, session);
return session;
}
async update(session: Session): Promise<Session> {
this.sessions.set(session.id, session);
return session;
}
async delete(id: string): Promise<void> {
this.sessions.delete(id);
}
async exists(id: string): Promise<boolean> {
return this.sessions.has(id);
}
// Test helper methods
clear(): void {
this.sessions.clear();
}
getAll(): Session[] {
return Array.from(this.sessions.values());
}
}