Files
gridpilot.gg/adapters/racing/ports/InMemoryDriverRatingProvider.ts
Marc Mintel 597bb48248
Some checks failed
Contract Testing / contract-tests (pull_request) Failing after 4m51s
Contract Testing / contract-snapshot (pull_request) Has been skipped
integration tests
2026-01-22 17:29:06 +01:00

41 lines
1.3 KiB
TypeScript

import type { DriverRatingProvider } from '@core/racing/application/ports/DriverRatingProvider';
import type { Logger } from '@core/shared/domain/Logger';
// TODO Provider doesnt exist in Clean Architecture
// TODO Hardcoded data here must be moved to a better place
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;
}
clear(): void {
this.logger.info('[InMemoryDriverRatingProvider] Clearing all data');
// No data to clear as this provider generates data on-the-fly
}
}