wip
This commit is contained in:
@@ -50,7 +50,7 @@ export class GetProfileOverviewUseCase {
|
||||
public readonly presenter: IProfileOverviewPresenter,
|
||||
) {}
|
||||
|
||||
async execute(params: GetProfileOverviewParams): Promise<void> {
|
||||
async execute(params: GetProfileOverviewParams): Promise<ProfileOverviewViewModel | null> {
|
||||
const { driverId } = params;
|
||||
|
||||
const driver = await this.driverRepository.findById(driverId);
|
||||
@@ -69,7 +69,7 @@ export class GetProfileOverviewUseCase {
|
||||
};
|
||||
|
||||
this.presenter.present(emptyViewModel);
|
||||
return;
|
||||
return emptyViewModel;
|
||||
}
|
||||
|
||||
const [statsAdapter, teams, friends] = await Promise.all([
|
||||
@@ -95,6 +95,7 @@ export class GetProfileOverviewUseCase {
|
||||
};
|
||||
|
||||
this.presenter.present(viewModel);
|
||||
return viewModel;
|
||||
}
|
||||
|
||||
private buildDriverSummary(
|
||||
@@ -103,6 +104,7 @@ export class GetProfileOverviewUseCase {
|
||||
): ProfileOverviewDriverSummaryViewModel {
|
||||
const rankings = this.getAllDriverRankings();
|
||||
const fallbackRank = this.computeFallbackRank(driver.id, rankings);
|
||||
const totalDrivers = rankings.length;
|
||||
|
||||
return {
|
||||
id: driver.id,
|
||||
@@ -110,13 +112,15 @@ export class GetProfileOverviewUseCase {
|
||||
country: driver.country,
|
||||
avatarUrl: this.imageService.getDriverAvatar(driver.id),
|
||||
iracingId: driver.iracingId ?? null,
|
||||
joinedAt: driver.joinedAt instanceof Date
|
||||
? driver.joinedAt.toISOString()
|
||||
: new Date(driver.joinedAt).toISOString(),
|
||||
joinedAt:
|
||||
driver.joinedAt instanceof Date
|
||||
? driver.joinedAt.toISOString()
|
||||
: new Date(driver.joinedAt).toISOString(),
|
||||
rating: stats?.rating ?? null,
|
||||
globalRank: stats?.overallRank ?? fallbackRank,
|
||||
consistency: stats?.consistency ?? null,
|
||||
bio: driver.bio ?? null,
|
||||
totalDrivers,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -161,6 +165,9 @@ export class GetProfileOverviewUseCase {
|
||||
winRate,
|
||||
podiumRate,
|
||||
percentile: stats.percentile,
|
||||
rating: stats.rating,
|
||||
consistency: stats.consistency,
|
||||
overallRank: stats.overallRank,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -417,8 +424,10 @@ export class GetProfileOverviewUseCase {
|
||||
'Flexible schedule',
|
||||
];
|
||||
|
||||
const socialHandles = socialOptions[hash % socialOptions.length];
|
||||
const achievementsSource = achievementSets[hash % achievementSets.length];
|
||||
const socialHandles =
|
||||
socialOptions[hash % socialOptions.length] ?? [];
|
||||
const achievementsSource =
|
||||
achievementSets[hash % achievementSets.length] ?? [];
|
||||
|
||||
return {
|
||||
socialHandles,
|
||||
@@ -430,11 +439,11 @@ export class GetProfileOverviewUseCase {
|
||||
rarity: achievement.rarity,
|
||||
earnedAt: achievement.earnedAt.toISOString(),
|
||||
})),
|
||||
racingStyle: styles[hash % styles.length],
|
||||
favoriteTrack: tracks[hash % tracks.length],
|
||||
favoriteCar: cars[hash % cars.length],
|
||||
timezone: timezones[hash % timezones.length],
|
||||
availableHours: hours[hash % hours.length],
|
||||
racingStyle: styles[hash % styles.length] ?? 'Consistent Pacer',
|
||||
favoriteTrack: tracks[hash % tracks.length] ?? 'Unknown Track',
|
||||
favoriteCar: cars[hash % cars.length] ?? 'Unknown Car',
|
||||
timezone: timezones[hash % timezones.length] ?? 'UTC',
|
||||
availableHours: hours[hash % hours.length] ?? 'Flexible schedule',
|
||||
lookingForTeam: hash % 3 === 0,
|
||||
openToRequests: hash % 2 === 0,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user