wip
This commit is contained in:
@@ -1,38 +1,22 @@
|
||||
/**
|
||||
* Application Query: GetRaceProtestsQuery
|
||||
*
|
||||
* Use Case: GetRaceProtestsUseCase
|
||||
*
|
||||
* Returns all protests filed for a specific race, with driver details.
|
||||
* Orchestrates domain logic and delegates presentation to the presenter.
|
||||
*/
|
||||
|
||||
import type { IProtestRepository } from '../../domain/repositories/IProtestRepository';
|
||||
import type { IDriverRepository } from '../../domain/repositories/IDriverRepository';
|
||||
import type { ProtestStatus, ProtestIncident } from '../../domain/entities/Protest';
|
||||
import type { IRaceProtestsPresenter } from '../presenters/IRaceProtestsPresenter';
|
||||
|
||||
export interface RaceProtestDTO {
|
||||
id: string;
|
||||
raceId: string;
|
||||
protestingDriverId: string;
|
||||
protestingDriverName: string;
|
||||
accusedDriverId: string;
|
||||
accusedDriverName: string;
|
||||
incident: ProtestIncident;
|
||||
comment?: string;
|
||||
proofVideoUrl?: string;
|
||||
status: ProtestStatus;
|
||||
reviewedBy?: string;
|
||||
reviewedByName?: string;
|
||||
decisionNotes?: string;
|
||||
filedAt: string;
|
||||
reviewedAt?: string;
|
||||
}
|
||||
|
||||
export class GetRaceProtestsQuery {
|
||||
export class GetRaceProtestsUseCase {
|
||||
constructor(
|
||||
private readonly protestRepository: IProtestRepository,
|
||||
private readonly driverRepository: IDriverRepository,
|
||||
public readonly presenter: IRaceProtestsPresenter,
|
||||
) {}
|
||||
|
||||
async execute(raceId: string): Promise<RaceProtestDTO[]> {
|
||||
async execute(raceId: string): Promise<void> {
|
||||
const protests = await this.protestRepository.findByRaceId(raceId);
|
||||
|
||||
// Load all driver details in parallel
|
||||
@@ -56,22 +40,6 @@ export class GetRaceProtestsQuery {
|
||||
}
|
||||
});
|
||||
|
||||
return protests.map(protest => ({
|
||||
id: protest.id,
|
||||
raceId: protest.raceId,
|
||||
protestingDriverId: protest.protestingDriverId,
|
||||
protestingDriverName: driverMap.get(protest.protestingDriverId) || 'Unknown',
|
||||
accusedDriverId: protest.accusedDriverId,
|
||||
accusedDriverName: driverMap.get(protest.accusedDriverId) || 'Unknown',
|
||||
incident: protest.incident,
|
||||
comment: protest.comment,
|
||||
proofVideoUrl: protest.proofVideoUrl,
|
||||
status: protest.status,
|
||||
reviewedBy: protest.reviewedBy,
|
||||
reviewedByName: protest.reviewedBy ? driverMap.get(protest.reviewedBy) : undefined,
|
||||
decisionNotes: protest.decisionNotes,
|
||||
filedAt: protest.filedAt.toISOString(),
|
||||
reviewedAt: protest.reviewedAt?.toISOString(),
|
||||
}));
|
||||
this.presenter.present(protests, driverMap);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user