#nullable enable
using Baya.Application.Contracts.Persistence;
using Baya.Application.Models.Common;
using Baya.Application.Models.Reviews;
using Mediator;

namespace Baya.Application.Features.Reviews.Queries.GetTagAggregates;

internal sealed class GetTagAggregatesQueryHandler(IUnitOfWork unitOfWork)
    : IRequestHandler<GetTagAggregatesQuery, OperationResult<NurseTagAggregatesResult>>
{
    public async ValueTask<OperationResult<NurseTagAggregatesResult>> Handle(
        GetTagAggregatesQuery request, CancellationToken cancellationToken)
    {
        var result = await unitOfWork.ReviewRepository.GetTagAggregatesAsync(request.NurseProfileId, cancellationToken);
        return OperationResult<NurseTagAggregatesResult>.SuccessResult(result);
    }
}
