refactor use cases

This commit is contained in:
2026-01-08 15:34:51 +01:00
parent d984ab24a8
commit 52e9a2f6a7
362 changed files with 5192 additions and 8409 deletions

View File

@@ -14,7 +14,6 @@ import {
AverageStrengthOfFieldCalculator,
type StrengthOfFieldCalculator,
} from '../../domain/services/StrengthOfFieldCalculator';
import type { UseCaseOutputPort } from '@core/shared/application/UseCaseOutputPort';
import type { Race } from '../../domain/entities/Race';
export interface GetRaceWithSOFInput {
@@ -41,7 +40,6 @@ export class GetRaceWithSOFUseCase {
private readonly registrationRepository: IRaceRegistrationRepository,
private readonly resultRepository: IResultRepository,
private readonly getDriverRating: GetDriverRating,
private readonly output: UseCaseOutputPort<GetRaceWithSOFResult>,
sofCalculator?: StrengthOfFieldCalculator,
) {
this.sofCalculator = sofCalculator ?? new AverageStrengthOfFieldCalculator();
@@ -49,7 +47,7 @@ export class GetRaceWithSOFUseCase {
async execute(
params: GetRaceWithSOFInput,
): Promise<Result<void, ApplicationErrorCode<GetRaceWithSOFErrorCode, { message: string }>>> {
): Promise<Result<GetRaceWithSOFResult, ApplicationErrorCode<GetRaceWithSOFErrorCode, { message: string }>>> {
const { raceId } = params;
try {
@@ -105,9 +103,7 @@ export class GetRaceWithSOFUseCase {
participantCount: participantIds.length,
};
this.output.present(result);
return Result.ok(undefined);
return Result.ok(result);
} catch (error) {
const message =
(error as Error)?.message ?? 'Failed to load race with SOF';