refactor core presenters
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import type { ILeagueMembershipRepository } from '../../domain/repositories/ILeagueMembershipRepository';
|
||||
import type { IRaceRepository } from '../../domain/repositories/IRaceRepository';
|
||||
import type { LeagueStatsViewModel } from '../presenters/ILeagueStatsPresenter';
|
||||
import type { LeagueStatsOutputPort } from '../ports/output/LeagueStatsOutputPort';
|
||||
import type { GetDriverRatingInputPort } from '../ports/input/GetDriverRatingInputPort';
|
||||
import type { GetDriverRatingOutputPort } from '../ports/output/GetDriverRatingOutputPort';
|
||||
import { Result } from '@core/shared/application/Result';
|
||||
@@ -17,7 +17,7 @@ export class GetLeagueStatsUseCase {
|
||||
private readonly getDriverRating: (input: GetDriverRatingInputPort) => Promise<GetDriverRatingOutputPort>,
|
||||
) {}
|
||||
|
||||
async execute(params: GetLeagueStatsUseCaseParams): Promise<Result<LeagueStatsViewModel, ApplicationErrorCode<'REPOSITORY_ERROR'>>> {
|
||||
async execute(params: GetLeagueStatsUseCaseParams): Promise<Result<LeagueStatsOutputPort, ApplicationErrorCode<'REPOSITORY_ERROR'>>> {
|
||||
try {
|
||||
const memberships = await this.leagueMembershipRepository.getLeagueMembers(params.leagueId);
|
||||
const races = await this.raceRepository.findByLeagueId(params.leagueId);
|
||||
@@ -35,7 +35,7 @@ export class GetLeagueStatsUseCase {
|
||||
|
||||
const averageRating = validRatings.length > 0 ? Math.round(validRatings.reduce((sum, r) => sum + r, 0) / validRatings.length) : 0;
|
||||
|
||||
const viewModel: LeagueStatsViewModel = {
|
||||
const viewModel: LeagueStatsOutputPort = {
|
||||
totalMembers: memberships.length,
|
||||
totalRaces: races.length,
|
||||
averageRating,
|
||||
|
||||
Reference in New Issue
Block a user