refactor use cases
This commit is contained in:
@@ -9,8 +9,6 @@ import { RecurrenceStrategyFactory } from '../../domain/value-objects/Recurrence
|
||||
import { WeekdaySet } from '../../domain/value-objects/WeekdaySet';
|
||||
import { MonthlyRecurrencePattern } from '../../domain/value-objects/MonthlyRecurrencePattern';
|
||||
import { ALL_WEEKDAYS, type Weekday } from '../../domain/types/Weekday';
|
||||
import type { UseCaseOutputPort } from '@core/shared/application/UseCaseOutputPort';
|
||||
|
||||
export type SeasonScheduleConfig = {
|
||||
seasonStartDate: string;
|
||||
recurrenceStrategy: 'weekly' | 'everyNWeeks' | 'monthlyNthWeekday';
|
||||
@@ -88,20 +86,17 @@ export type PreviewLeagueScheduleErrorCode =
|
||||
| 'REPOSITORY_ERROR';
|
||||
|
||||
export class PreviewLeagueScheduleUseCase {
|
||||
constructor(
|
||||
private readonly scheduleGenerator: Pick<
|
||||
constructor(private readonly scheduleGenerator: Pick<
|
||||
typeof SeasonScheduleGenerator,
|
||||
'generateSlotsUpTo'
|
||||
> = SeasonScheduleGenerator,
|
||||
private readonly logger: Logger,
|
||||
private readonly output: UseCaseOutputPort<PreviewLeagueScheduleResult>,
|
||||
) {}
|
||||
private readonly logger: Logger) {}
|
||||
|
||||
async execute(
|
||||
params: PreviewLeagueScheduleInput,
|
||||
): Promise<
|
||||
Result<
|
||||
void,
|
||||
PreviewLeagueScheduleResult,
|
||||
ApplicationErrorCode<PreviewLeagueScheduleErrorCode, { message: string }>
|
||||
>
|
||||
> {
|
||||
@@ -149,9 +144,7 @@ export class PreviewLeagueScheduleUseCase {
|
||||
roundCount: rounds.length,
|
||||
});
|
||||
|
||||
this.output.present(result);
|
||||
|
||||
return Result.ok(undefined);
|
||||
return Result.ok(result);
|
||||
} catch (error) {
|
||||
this.logger.error(
|
||||
'Failed to preview league schedule due to an unexpected error',
|
||||
|
||||
Reference in New Issue
Block a user