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
  }
}
