This commit is contained in:
2025-12-16 21:44:20 +01:00
parent 7532c7ed6d
commit 8c67081953
38 changed files with 818 additions and 1321 deletions

View File

@@ -10,7 +10,7 @@ export interface GetLeagueSeasonsUseCaseParams {
export class GetLeagueSeasonsUseCase {
constructor(private readonly seasonRepository: ISeasonRepository) {}
async execute(params: GetLeagueSeasonsUseCaseParams): Promise<Result<GetLeagueSeasonsViewModel, ApplicationErrorCode<'REPOSITORY_ERROR'>>> {
async execute(params: GetLeagueSeasonsUseCaseParams): Promise<Result<GetLeagueSeasonsViewModel, ApplicationErrorCode<'REPOSITORY_ERROR', { message: string }>>> {
try {
const seasons = await this.seasonRepository.findByLeagueId(params.leagueId);
const activeCount = seasons.filter(s => s.status === 'active').length;
@@ -19,15 +19,15 @@ export class GetLeagueSeasonsUseCase {
seasonId: s.id,
name: s.name,
status: s.status,
startDate: s.startDate,
endDate: s.endDate,
startDate: s.startDate ?? new Date(),
endDate: s.endDate ?? new Date(),
isPrimary: false,
isParallelActive: s.status === 'active' && activeCount > 1
}))
};
return Result.ok(viewModel);
} catch {
return Result.err({ code: 'REPOSITORY_ERROR', message: 'Failed to fetch seasons' });
return Result.err({ code: 'REPOSITORY_ERROR', details: { message: 'Failed to fetch seasons' } });
}
}
}