refactor use cases
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import { Result } from '@core/shared/application/Result';
|
||||
import type { UseCaseOutputPort } from '@core/shared/application';
|
||||
import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode';
|
||||
import type { IDriverRepository } from '../../domain/repositories/IDriverRepository';
|
||||
import type { ILeagueRepository } from '../../domain/repositories/ILeagueRepository';
|
||||
@@ -39,13 +38,12 @@ export class GetRaceResultsDetailUseCase {
|
||||
private readonly resultRepository: IResultRepository,
|
||||
private readonly driverRepository: IDriverRepository,
|
||||
private readonly penaltyRepository: IPenaltyRepository,
|
||||
private readonly output: UseCaseOutputPort<GetRaceResultsDetailResult>,
|
||||
) {}
|
||||
|
||||
async execute(
|
||||
params: GetRaceResultsDetailInput,
|
||||
): Promise<
|
||||
Result<void, ApplicationErrorCode<GetRaceResultsDetailErrorCode, { message: string }>>
|
||||
Result<GetRaceResultsDetailResult, ApplicationErrorCode<GetRaceResultsDetailErrorCode, { message: string }>>
|
||||
> {
|
||||
try {
|
||||
const { raceId, driverId } = params;
|
||||
@@ -83,9 +81,7 @@ export class GetRaceResultsDetailUseCase {
|
||||
...(effectiveCurrentDriverId ? { currentDriverId: effectiveCurrentDriverId } : {}),
|
||||
};
|
||||
|
||||
this.output.present(result);
|
||||
|
||||
return Result.ok(undefined);
|
||||
return Result.ok(result);
|
||||
} catch (error: unknown) {
|
||||
const message =
|
||||
error instanceof Error && typeof error.message === 'string'
|
||||
@@ -151,4 +147,4 @@ export class GetRaceResultsDetailUseCase {
|
||||
if (results.length === 0) return undefined;
|
||||
return Math.min(...results.map(r => r.fastestLap.toNumber()));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user