fix issues in core

This commit is contained in:
2025-12-23 11:25:08 +01:00
parent 1efd971032
commit 2854ae3c5c
113 changed files with 1142 additions and 458 deletions

View File

@@ -57,13 +57,19 @@ export class CompleteRaceUseCase {
const race = await this.raceRepository.findById(raceId);
if (!race) {
return Result.err({ code: 'RACE_NOT_FOUND' });
return Result.err<void, ApplicationErrorCode<CompleteRaceErrorCode, { message: string }>>({
code: 'RACE_NOT_FOUND',
details: { message: 'Race not found' },
});
}
// Get registered drivers for this race
const registeredDriverIds = await this.raceRegistrationRepository.getRegisteredDrivers(raceId);
if (registeredDriverIds.length === 0) {
return Result.err({ code: 'NO_REGISTERED_DRIVERS' });
return Result.err<void, ApplicationErrorCode<CompleteRaceErrorCode, { message: string }>>({
code: 'NO_REGISTERED_DRIVERS',
details: { message: 'No registered drivers for this race' },
});
}
// Get driver ratings using injected provider
@@ -175,9 +181,10 @@ export class CompleteRaceUseCase {
// Group results by driver
const resultsByDriver = new Map<string, RaceResult[]>();
for (const result of results) {
const existing = resultsByDriver.get(result.driverId) || [];
const driverIdStr = result.driverId.toString();
const existing = resultsByDriver.get(driverIdStr) || [];
existing.push(result);
resultsByDriver.set(result.driverId, existing);
resultsByDriver.set(driverIdStr, existing);
}
// Update or create standings for each driver
@@ -193,7 +200,7 @@ export class CompleteRaceUseCase {
// Add all results for this driver (should be just one for this race)
for (const result of driverResults) {
standing = standing.addRaceResult(result.position, {
standing = standing.addRaceResult(result.position.toNumber(), {
1: 25, 2: 18, 3: 15, 4: 12, 5: 10, 6: 8, 7: 6, 8: 4, 9: 2, 10: 1
});
}