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

@@ -4,7 +4,6 @@ import { SkillLevelService, type SkillLevel } from '@core/racing/domain/services
import { Result } from '@core/shared/application/Result';
import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode';
import type { Logger } from '@core/shared/application';
import type { UseCaseOutputPort } from '@core/shared/application/UseCaseOutputPort';
import type { Team } from '@core/racing/domain/entities/Team';
interface DriverStatsAdapter {
@@ -47,12 +46,11 @@ export class GetTeamsLeaderboardUseCase {
private readonly teamMembershipRepository: ITeamMembershipRepository,
private readonly getDriverStats: (driverId: string) => DriverStatsAdapter | null,
private readonly logger: Logger,
private readonly output: UseCaseOutputPort<GetTeamsLeaderboardResult>,
) {}
async execute(
_input: GetTeamsLeaderboardInput,
): Promise<Result<void, ApplicationErrorCode<GetTeamsLeaderboardErrorCode, { message: string }>>> {
): Promise<Result<GetTeamsLeaderboardResult, ApplicationErrorCode<GetTeamsLeaderboardErrorCode, { message: string }>>> {
void _input;
try {
const allTeams = await this.teamRepository.findAll();
@@ -116,14 +114,14 @@ export class GetTeamsLeaderboardUseCase {
.sort((a, b) => (b.rating ?? 0) - (a.rating ?? 0))
.slice(0, 10);
this.output.present({
const result: GetTeamsLeaderboardResult = {
items,
recruitingCount,
groupsBySkillLevel,
topItems,
});
};
return Result.ok(undefined);
return Result.ok(result);
} catch (err) {
const error = err as { message?: string } | undefined;
@@ -135,4 +133,4 @@ export class GetTeamsLeaderboardUseCase {
});
}
}
}
}