Files
gridpilot.gg/adapters/racing/ports/InMemoryDriverRatingProvider.ts
2025-12-16 11:52:26 +01:00

33 lines
1.1 KiB
TypeScript

import type { DriverRatingProvider } from '@core/racing/application/ports/DriverRatingProvider';
import type { Logger } from '@core/shared/logging/Logger';
export class InMemoryDriverRatingProvider implements DriverRatingProvider {
constructor(private readonly logger: Logger) {
this.logger.info('InMemoryDriverRatingProvider initialized.');
}
getRating(driverId: string): number | null {
this.logger.debug(`[InMemoryDriverRatingProvider] Getting rating for driver: ${driverId}`);
// Mock data for demonstration purposes
if (driverId === 'driver-1') {
return 2500;
}
if (driverId === 'driver-2') {
return 2400;
}
return null;
}
getRatings(driverIds: string[]): Map<string, number> {
this.logger.debug(`[InMemoryDriverRatingProvider] Getting ratings for drivers: ${driverIds.join(', ')}`);
const ratingsMap = new Map<string, number>();
for (const driverId of driverIds) {
const rating = this.getRating(driverId);
if (rating !== null) {
ratingsMap.set(driverId, rating);
}
}
return ratingsMap;
}
}