merge
Some checks failed
CI / lint-typecheck (pull_request) Failing after 4m51s
CI / tests (pull_request) Has been skipped
CI / contract-tests (pull_request) Has been skipped
CI / e2e-tests (pull_request) Has been skipped
CI / comment-pr (pull_request) Has been skipped
CI / commit-types (pull_request) Has been skipped
Some checks failed
CI / lint-typecheck (pull_request) Failing after 4m51s
CI / tests (pull_request) Has been skipped
CI / contract-tests (pull_request) Has been skipped
CI / e2e-tests (pull_request) Has been skipped
CI / comment-pr (pull_request) Has been skipped
CI / commit-types (pull_request) Has been skipped
This commit is contained in:
@@ -6,7 +6,7 @@ import { Provider } from '@nestjs/common';
|
||||
import {
|
||||
ANALYTICS_ENGAGEMENT_REPOSITORY_TOKEN,
|
||||
ANALYTICS_PAGE_VIEW_REPOSITORY_TOKEN,
|
||||
} from '../../../../persistence/analytics/AnalyticsPersistenceTokens';
|
||||
} from '../../persistence/analytics/AnalyticsPersistenceTokens';
|
||||
|
||||
const LOGGER_TOKEN = 'Logger';
|
||||
|
||||
|
||||
@@ -140,10 +140,9 @@ export const SponsorProviders: Provider[] = [
|
||||
useFactory: (
|
||||
paymentRepo: PaymentRepository,
|
||||
seasonSponsorshipRepo: SeasonSponsorshipRepository,
|
||||
) => {
|
||||
return new GetSponsorBillingUseCase(paymentRepo, seasonSponsorshipRepo);
|
||||
},
|
||||
inject: [PAYMENT_REPOSITORY_TOKEN, SEASON_SPONSORSHIP_REPOSITORY_TOKEN],
|
||||
sponsorRepo: SponsorRepository,
|
||||
) => new GetSponsorBillingUseCase(paymentRepo, seasonSponsorshipRepo, sponsorRepo),
|
||||
inject: [PAYMENT_REPOSITORY_TOKEN, SEASON_SPONSORSHIP_REPOSITORY_TOKEN, SPONSOR_REPOSITORY_TOKEN],
|
||||
},
|
||||
{
|
||||
provide: GET_ENTITY_SPONSORSHIP_PRICING_USE_CASE_TOKEN,
|
||||
|
||||
@@ -6,6 +6,9 @@ import type { ViewDataBuilder } from '@/lib/contracts/builders/ViewDataBuilder';
|
||||
|
||||
export class LeaguesViewDataBuilder {
|
||||
public static build(apiDto: AllLeaguesWithCapacityAndScoringDTO): LeaguesViewData {
|
||||
if (!apiDto || !Array.isArray(apiDto.leagues)) {
|
||||
return { leagues: [] };
|
||||
}
|
||||
return {
|
||||
leagues: apiDto.leagues.map((league) => ({
|
||||
id: league.id,
|
||||
|
||||
@@ -2,14 +2,16 @@ import { PageQuery } from '@/lib/contracts/page-queries/PageQuery';
|
||||
import { Result } from '@/lib/contracts/Result';
|
||||
import { LeagueService, type LeagueDetailData } from '@/lib/services/leagues/LeagueService';
|
||||
import { type PresentationError, mapToPresentationError } from '@/lib/contracts/page-queries/PresentationError';
|
||||
import { LeagueDetailViewDataBuilder } from '@/lib/builders/view-data/LeagueDetailViewDataBuilder';
|
||||
import { LeagueDetailViewData } from '@/lib/view-data/LeagueDetailViewData';
|
||||
|
||||
/**
|
||||
* LeagueDetail page query
|
||||
* Returns the raw API DTO for the league detail page
|
||||
* No DI container usage - constructs dependencies explicitly
|
||||
*/
|
||||
export class LeagueDetailPageQuery implements PageQuery<LeagueDetailData, string, PresentationError> {
|
||||
async execute(leagueId: string): Promise<Result<LeagueDetailData, PresentationError>> {
|
||||
export class LeagueDetailPageQuery implements PageQuery<LeagueDetailViewData, string, PresentationError> {
|
||||
async execute(leagueId: string): Promise<Result<LeagueDetailViewData, PresentationError>> {
|
||||
const service = new LeagueService();
|
||||
const result = await service.getLeagueDetailData(leagueId);
|
||||
|
||||
@@ -17,11 +19,12 @@ export class LeagueDetailPageQuery implements PageQuery<LeagueDetailData, string
|
||||
return Result.err(mapToPresentationError(result.getError()));
|
||||
}
|
||||
|
||||
return Result.ok(result.unwrap());
|
||||
const viewData = LeagueDetailViewDataBuilder.build(result.unwrap());
|
||||
return Result.ok(viewData);
|
||||
}
|
||||
|
||||
// Static method to avoid object construction in server code
|
||||
static async execute(leagueId: string): Promise<Result<LeagueDetailData, PresentationError>> {
|
||||
static async execute(leagueId: string): Promise<Result<LeagueDetailViewData, PresentationError>> {
|
||||
const query = new LeagueDetailPageQuery();
|
||||
return query.execute(leagueId);
|
||||
}
|
||||
|
||||
@@ -33,7 +33,11 @@ export class LeaguesPageQuery implements PageQuery<LeaguesViewData, void> {
|
||||
}
|
||||
|
||||
// Transform to ViewData using builder
|
||||
const viewData = LeaguesViewDataBuilder.build(result.unwrap());
|
||||
const apiDto = result.unwrap();
|
||||
if (!apiDto || !apiDto.leagues) {
|
||||
return Result.err('UNKNOWN_ERROR');
|
||||
}
|
||||
const viewData = LeaguesViewDataBuilder.build(apiDto);
|
||||
return Result.ok(viewData);
|
||||
}
|
||||
|
||||
|
||||
@@ -169,27 +169,28 @@ export class LeagueService implements Service {
|
||||
this.racesApiClient.getPageData(leagueId),
|
||||
]);
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
if (process.env.NODE_ENV !== 'production' && process.env.NODE_ENV !== 'test') {
|
||||
const membershipCount = Array.isArray(memberships?.members) ? memberships.members.length : 0;
|
||||
const racesCount = Array.isArray(racesPageData?.races) ? racesPageData.races.length : 0;
|
||||
const race0 = racesCount > 0 ? racesPageData.races[0] : null;
|
||||
|
||||
console.info(
|
||||
'[LeagueService.getLeagueDetailData] baseUrl=%s leagueId=%s memberships=%d races=%d race0=%o',
|
||||
'[LeagueService.getLeagueDetailData] baseUrl=%s leagueId=%s memberships=%d races=%d race0=%o apiDto=%o',
|
||||
this.baseUrl,
|
||||
leagueId,
|
||||
membershipCount,
|
||||
racesCount,
|
||||
race0,
|
||||
apiDto
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
if (!apiDto || !apiDto.leagues) {
|
||||
return Result.err({ type: 'notFound', message: 'Leagues not found' });
|
||||
}
|
||||
|
||||
const league = apiDto.leagues.find(l => l.id === leagueId);
|
||||
const leagues = Array.isArray(apiDto.leagues) ? apiDto.leagues : [];
|
||||
const league = leagues.find(l => l.id === leagueId);
|
||||
if (!league) {
|
||||
return Result.err({ type: 'notFound', message: 'League not found' });
|
||||
}
|
||||
@@ -220,7 +221,7 @@ export class LeagueService implements Service {
|
||||
console.warn('Failed to fetch league scoring config', e);
|
||||
}
|
||||
|
||||
const races: RaceDTO[] = (racesPageData.races || []).map((r) => ({
|
||||
const races: RaceDTO[] = (racesPageData?.races || []).map((r) => ({
|
||||
id: r.id,
|
||||
name: `${r.track} - ${r.car}`,
|
||||
date: r.scheduledAt,
|
||||
|
||||
Reference in New Issue
Block a user