using MediatR;
using MiningService.Domain.AggregatesModel.MinerAggregate;

namespace MiningService.API.Application.Queries;

/// <summary>
/// EN: Query for admin dashboard overview.
/// VI: Query tổng quan dashboard admin.
/// </summary>
public record GetAdminOverviewQuery() : IRequest<AdminOverviewDto>;

public record AdminOverviewDto(
    int TotalMiners,
    int ActiveMiners,
    int MinersWithActiveSession,
    decimal TotalPointsMined,
    int TotalCircles,
    int ValidCircles,
    int TotalReferrals,
    int ActiveReferrals);

public class GetAdminOverviewQueryHandler : IRequestHandler<GetAdminOverviewQuery, AdminOverviewDto>
{
    private readonly IMinerRepository _minerRepository;

    public GetAdminOverviewQueryHandler(IMinerRepository minerRepository)
    {
        _minerRepository = minerRepository;
    }

    public async Task<AdminOverviewDto> Handle(GetAdminOverviewQuery request, CancellationToken cancellationToken)
    {
        // Note: In production, use Dapper for read-optimized queries
        // This is a simplified version
        return new AdminOverviewDto(
            TotalMiners: 0,           // TODO: Implement with Dapper
            ActiveMiners: 0,
            MinersWithActiveSession: 0,
            TotalPointsMined: 0,
            TotalCircles: 0,
            ValidCircles: 0,
            TotalReferrals: 0,
            ActiveReferrals: 0);
    }
}
