code quality
Some checks failed
CI / lint-typecheck (pull_request) Failing after 10s
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 10s
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:
@@ -13,48 +13,69 @@ export class DriverProfileViewDataBuilder {
|
||||
public static build(apiDto: GetDriverProfileOutputDTO): DriverProfileViewData {
|
||||
const currentDriver = apiDto.currentDriver!;
|
||||
return {
|
||||
driver: {
|
||||
currentDriver: {
|
||||
id: currentDriver.id,
|
||||
name: currentDriver.name,
|
||||
countryCode: currentDriver.country,
|
||||
countryFlag: currentDriver.country, // Placeholder
|
||||
country: currentDriver.country,
|
||||
avatarUrl: currentDriver.avatarUrl || '',
|
||||
bio: currentDriver.bio ?? null,
|
||||
iracingId: currentDriver.iracingId ?? null,
|
||||
iracingId: currentDriver.iracingId ? parseInt(currentDriver.iracingId, 10) : null,
|
||||
joinedAt: currentDriver.joinedAt,
|
||||
joinedAtLabel: DateFormatter.formatMonthYear(currentDriver.joinedAt),
|
||||
rating: currentDriver.rating ?? null,
|
||||
ratingLabel: RatingFormatter.format(currentDriver.rating),
|
||||
globalRank: currentDriver.globalRank ?? null,
|
||||
globalRankLabel: currentDriver.globalRank != null ? `#${currentDriver.globalRank}` : '—',
|
||||
},
|
||||
consistency: currentDriver.consistency ?? null,
|
||||
bio: currentDriver.bio ?? null,
|
||||
totalDrivers: currentDriver.totalDrivers ?? null,
|
||||
} as any,
|
||||
stats: apiDto.stats ? {
|
||||
ratingLabel: RatingFormatter.format(apiDto.stats.rating),
|
||||
globalRankLabel: apiDto.stats.overallRank != null ? `#${apiDto.stats.overallRank}` : '—',
|
||||
totalRaces: apiDto.stats.totalRaces,
|
||||
totalRacesLabel: NumberFormatter.format(apiDto.stats.totalRaces),
|
||||
wins: apiDto.stats.wins,
|
||||
winsLabel: NumberFormatter.format(apiDto.stats.wins),
|
||||
podiums: apiDto.stats.podiums,
|
||||
podiumsLabel: NumberFormatter.format(apiDto.stats.podiums),
|
||||
dnfs: apiDto.stats.dnfs,
|
||||
dnfsLabel: NumberFormatter.format(apiDto.stats.dnfs),
|
||||
bestFinishLabel: FinishFormatter.format(apiDto.stats.bestFinish),
|
||||
worstFinishLabel: FinishFormatter.format(apiDto.stats.worstFinish),
|
||||
avgFinish: apiDto.stats.avgFinish ?? null,
|
||||
avgFinishLabel: FinishFormatter.formatAverage(apiDto.stats.avgFinish),
|
||||
bestFinish: apiDto.stats.bestFinish ?? null,
|
||||
bestFinishLabel: FinishFormatter.format(apiDto.stats.bestFinish),
|
||||
worstFinish: apiDto.stats.worstFinish ?? null,
|
||||
worstFinishLabel: FinishFormatter.format(apiDto.stats.worstFinish),
|
||||
finishRate: apiDto.stats.finishRate ?? null,
|
||||
winRate: apiDto.stats.winRate ?? null,
|
||||
podiumRate: apiDto.stats.podiumRate ?? null,
|
||||
percentile: apiDto.stats.percentile ?? null,
|
||||
rating: apiDto.stats.rating ?? null,
|
||||
ratingLabel: RatingFormatter.format(apiDto.stats.rating),
|
||||
consistency: apiDto.stats.consistency ?? null,
|
||||
consistencyLabel: PercentFormatter.formatWhole(apiDto.stats.consistency),
|
||||
percentileLabel: PercentFormatter.formatWhole(apiDto.stats.percentile),
|
||||
overallRank: apiDto.stats.overallRank ?? null,
|
||||
} as any : null,
|
||||
finishDistribution: apiDto.finishDistribution ?? null,
|
||||
teamMemberships: apiDto.teamMemberships.map(m => ({
|
||||
teamId: m.teamId,
|
||||
teamName: m.teamName,
|
||||
teamTag: m.teamTag ?? null,
|
||||
roleLabel: m.role,
|
||||
role: m.role,
|
||||
joinedAt: m.joinedAt,
|
||||
joinedAtLabel: DateFormatter.formatMonthYear(m.joinedAt),
|
||||
href: `/teams/${m.teamId}`,
|
||||
})) as any,
|
||||
isCurrent: m.isCurrent,
|
||||
})),
|
||||
socialSummary: {
|
||||
friendsCount: apiDto.socialSummary.friendsCount,
|
||||
friends: apiDto.socialSummary.friends.map(f => ({
|
||||
id: f.id,
|
||||
name: f.name,
|
||||
country: f.country,
|
||||
avatarUrl: f.avatarUrl || '',
|
||||
})),
|
||||
},
|
||||
extendedProfile: apiDto.extendedProfile ? {
|
||||
timezone: apiDto.extendedProfile.timezone,
|
||||
racingStyle: apiDto.extendedProfile.racingStyle,
|
||||
favoriteTrack: apiDto.extendedProfile.favoriteTrack,
|
||||
favoriteCar: apiDto.extendedProfile.favoriteCar,
|
||||
availableHours: apiDto.extendedProfile.availableHours,
|
||||
lookingForTeamLabel: apiDto.extendedProfile.lookingForTeam ? 'Yes' : 'No',
|
||||
openToRequestsLabel: apiDto.extendedProfile.openToRequests ? 'Yes' : 'No',
|
||||
socialHandles: apiDto.extendedProfile.socialHandles.map(h => ({
|
||||
platformLabel: h.platform,
|
||||
platform: h.platform,
|
||||
handle: h.handle,
|
||||
url: h.url,
|
||||
})),
|
||||
@@ -62,20 +83,21 @@ export class DriverProfileViewDataBuilder {
|
||||
id: a.id,
|
||||
title: a.title,
|
||||
description: a.description,
|
||||
icon: a.icon,
|
||||
rarity: a.rarity,
|
||||
rarityLabel: a.rarity, // Placeholder
|
||||
earnedAt: a.earnedAt,
|
||||
earnedAtLabel: DateFormatter.formatShort(a.earnedAt),
|
||||
icon: a.icon as any,
|
||||
rarityLabel: a.rarity,
|
||||
})),
|
||||
friends: apiDto.socialSummary.friends.map(f => ({
|
||||
id: f.id,
|
||||
name: f.name,
|
||||
countryFlag: f.country, // Placeholder
|
||||
avatarUrl: f.avatarUrl || '',
|
||||
href: `/drivers/${f.id}`,
|
||||
})),
|
||||
friendsCountLabel: NumberFormatter.format(apiDto.socialSummary.friendsCount),
|
||||
} as any : null,
|
||||
} as any;
|
||||
racingStyle: apiDto.extendedProfile.racingStyle,
|
||||
favoriteTrack: apiDto.extendedProfile.favoriteTrack,
|
||||
favoriteCar: apiDto.extendedProfile.favoriteCar,
|
||||
timezone: apiDto.extendedProfile.timezone,
|
||||
availableHours: apiDto.extendedProfile.availableHours,
|
||||
lookingForTeam: apiDto.extendedProfile.lookingForTeam,
|
||||
openToRequests: apiDto.extendedProfile.openToRequests,
|
||||
} : null,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user