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

@@ -1,5 +1,4 @@
import { Result } from '@core/shared/application/Result';
import type { UseCaseOutputPort } from '@core/shared/application/UseCaseOutputPort';
import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode';
import type { IDriverRepository } from '../../domain/repositories/IDriverRepository';
import type { IPenaltyRepository } from '../../domain/repositories/IPenaltyRepository';
@@ -49,20 +48,17 @@ export type GetLeagueDriverSeasonStatsErrorCode =
* Orchestrates domain logic and returns the result.
*/
export class GetLeagueDriverSeasonStatsUseCase {
constructor(
private readonly standingRepository: IStandingRepository,
constructor(private readonly standingRepository: IStandingRepository,
private readonly resultRepository: IResultRepository,
private readonly penaltyRepository: IPenaltyRepository,
private readonly raceRepository: IRaceRepository,
private readonly driverRepository: IDriverRepository,
private readonly driverRatingPort: DriverRatingPort,
private readonly output: UseCaseOutputPort<GetLeagueDriverSeasonStatsResult>,
) {}
private readonly driverRatingPort: DriverRatingPort) {}
async execute(
input: GetLeagueDriverSeasonStatsInput,
): Promise<
Result<void, ApplicationErrorCode<GetLeagueDriverSeasonStatsErrorCode, { message: string }>>
Result<GetLeagueDriverSeasonStatsResult, ApplicationErrorCode<GetLeagueDriverSeasonStatsErrorCode, { message: string }>>
> {
try {
const { leagueId } = input;
@@ -167,9 +163,7 @@ export class GetLeagueDriverSeasonStatsUseCase {
stats,
};
this.output.present(result);
return Result.ok(undefined);
return Result.ok(result);
} catch (error) {
const message =
error instanceof Error && error.message