using CMSMicroservice.Application.Common.Interfaces;

namespace CMSMicroservice.Application.CommissionCQ.Queries.GetWorkerStatus;

public class GetWorkerStatusQueryHandler : IRequestHandler<GetWorkerStatusQuery, GetWorkerStatusResponseDto>
{
    private readonly IApplicationDbContext _context;

    public GetWorkerStatusQueryHandler(IApplicationDbContext context)
    {
        _context = context;
    }

    public async Task<GetWorkerStatusResponseDto> Handle(
        GetWorkerStatusQuery request,
        CancellationToken cancellationToken)
    {
        // TODO: این باید از یک service یا cache واقعی worker status را بگیرد
        // فعلاً mock data برمی‌گرداند
        
        await Task.CompletedTask;

        return new GetWorkerStatusResponseDto
        {
            IsRunning = false,
            IsEnabled = true,
            CurrentExecutionId = null,
            CurrentWeekNumber = null,
            CurrentStep = "Idle",
            LastRunAt = DateTime.UtcNow.AddHours(-24),
            NextScheduledRun = DateTime.UtcNow.AddDays(7),
            TotalExecutions = 48,
            SuccessfulExecutions = 47,
            FailedExecutions = 1
        };
    }
}
