import { Inject } from '@nestjs/common';
import { type IQueryHandler, QueryHandler } from '@nestjs/cqrs';
import {
  INDUSTRIAL_PARK_REPOSITORY,
  type IIndustrialParkRepository,
  type IndustrialParkStatsData,
} from '../../../domain/repositories/industrial-park.repository';
import { IndustrialParkStatsQuery } from './industrial-park-stats.query';

@QueryHandler(IndustrialParkStatsQuery)
export class IndustrialParkStatsHandler implements IQueryHandler<IndustrialParkStatsQuery> {
  constructor(
    @Inject(INDUSTRIAL_PARK_REPOSITORY)
    private readonly repo: IIndustrialParkRepository,
  ) {}

  async execute(_query: IndustrialParkStatsQuery): Promise<IndustrialParkStatsData> {
    return this.repo.getStats();
  }
}
