using Knot.Contracts.Messaging.Application.Abstractions;
using ModuleUserStats = Knot.Modules.Messaging.Application.Abstractions.UserStats;
using ModuleUserStatsService = Knot.Modules.Messaging.Application.Abstractions.IUserStatsService;

namespace Knot.Modules.Messaging.Infrastructure.Adapters;

internal sealed class UserStatsServiceAdapter : IUserStatsService
{
    private readonly ModuleUserStatsService _inner;

    public UserStatsServiceAdapter(ModuleUserStatsService inner)
    {
        _inner = inner;
    }

    public async Task<Dictionary<Guid, UserStats>> GetStatsForUsersAsync(List<Guid> userIds, CancellationToken cancellationToken = default)
    {
        var moduleStats = await _inner.GetStatsForUsersAsync(userIds, cancellationToken);
        return moduleStats.ToDictionary(
            kvp => kvp.Key,
            kvp => new UserStats(kvp.Value.MessageCount, kvp.Value.StorageSize)
        );
    }
}
