module creation
This commit is contained in:
32
adapters/racing/ports/InMemoryDriverRatingProvider.ts
Normal file
32
adapters/racing/ports/InMemoryDriverRatingProvider.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import type { DriverRatingProvider } from '@gridpilot/racing/application/ports/DriverRatingProvider';
|
||||
import type { ILogger } from '@gridpilot/shared/logging/ILogger';
|
||||
|
||||
export class InMemoryDriverRatingProvider implements DriverRatingProvider {
|
||||
constructor(private readonly logger: ILogger) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user