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,4 +1,4 @@
import type { Logger, UseCase, UseCaseOutputPort } from '@core/shared/application';
import type { Logger, UseCase } from '@core/shared/application';
import { Result } from '@core/shared/application/Result';
import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode';
import type { Driver } from '../../domain/entities/Driver';
@@ -43,20 +43,19 @@ export type GetDriversLeaderboardErrorCode =
* Use Case for retrieving driver leaderboard data.
* Returns a Result containing the domain leaderboard model.
*/
export class GetDriversLeaderboardUseCase implements UseCase<GetDriversLeaderboardInput, void, GetDriversLeaderboardErrorCode> {
export class GetDriversLeaderboardUseCase implements UseCase<GetDriversLeaderboardInput, GetDriversLeaderboardResult, GetDriversLeaderboardErrorCode> {
constructor(
private readonly driverRepository: IDriverRepository,
private readonly rankingUseCase: IRankingUseCase,
private readonly driverStatsUseCase: IDriverStatsUseCase,
private readonly logger: Logger,
private readonly output: UseCaseOutputPort<GetDriversLeaderboardResult>,
) {}
async execute(
input: GetDriversLeaderboardInput,
): Promise<
Result<
void,
GetDriversLeaderboardResult,
ApplicationErrorCode<GetDriversLeaderboardErrorCode, { message: string }>
>
> {
@@ -111,9 +110,7 @@ export class GetDriversLeaderboardUseCase implements UseCase<GetDriversLeaderboa
this.logger.debug('Successfully computed drivers leaderboard');
this.output.present(result);
return Result.ok(void 0);
return Result.ok(result);
} catch (error) {
const err = error instanceof Error ? error : new Error(String(error));