refactor use cases
This commit is contained in:
@@ -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';
|
||||
|
||||
Reference in New Issue
Block a user