import { Inject } from '@nestjs/common';
import { type IQueryHandler, QueryHandler } from '@nestjs/cqrs';
import {
  TRANSFER_LISTING_REPOSITORY,
  type ITransferListingRepository,
} from '../../../domain/repositories/transfer-listing.repository';
import { TransferStatsQuery } from './transfer-stats.query';

@QueryHandler(TransferStatsQuery)
export class TransferStatsHandler implements IQueryHandler<TransferStatsQuery> {
  constructor(
    @Inject(TRANSFER_LISTING_REPOSITORY)
    private readonly repo: ITransferListingRepository,
  ) {}

  async execute(_query: TransferStatsQuery) {
    return this.repo.getStats();
  }
}
