namespace MissionService.Domain.AggregatesModel.TaskAggregate;

using MissionService.Domain.SeedWork;

/// <summary>
/// EN: Repository interface for UserTask aggregate
/// VI: Interface repository cho UserTask aggregate  
/// </summary>
public interface IUserTaskRepository : IRepository<UserTask>
{
    /// <summary>
    /// EN: Add a new task / VI: Thêm task mới
    /// </summary>
    UserTask Add(UserTask task);
    
    /// <summary>
    /// EN: Update an existing task / VI: Cập nhật task
    /// </summary>
    void Update(UserTask task);
    
    /// <summary>
    /// EN: Get task by ID / VI: Lấy task theo ID
    /// </summary>
    Task<UserTask?> GetByIdAsync(Guid id, CancellationToken ct = default);
    
    /// <summary>
    /// EN: Get tasks by user ID / VI: Lấy tasks theo user ID
    /// </summary>
    Task<IReadOnlyList<UserTask>> GetByUserIdAsync(Guid userId, CancellationToken ct = default);
    
    /// <summary>
    /// EN: Get active tasks by user / VI: Lấy tasks đang hoạt động của user
    /// </summary>
    Task<IReadOnlyList<UserTask>> GetActiveByUserIdAsync(Guid userId, CancellationToken ct = default);
    
    /// <summary>
    /// EN: Get task by user and mission / VI: Lấy task theo user và mission
    /// </summary>
    Task<UserTask?> GetByUserAndMissionAsync(Guid userId, Guid missionId, CancellationToken ct = default);
    
    /// <summary>
    /// EN: Get completed tasks by user for period / VI: Lấy tasks đã hoàn thành trong khoảng thời gian
    /// </summary>
    Task<IReadOnlyList<UserTask>> GetCompletedByUserAsync(
        Guid userId, 
        DateTime fromDate, 
        DateTime toDate, 
        CancellationToken ct = default);
    
    /// <summary>
    /// EN: Count completions by user and mission / VI: Đếm số lần hoàn thành theo user và mission
    /// </summary>
    Task<int> CountCompletionsByUserAndMissionAsync(
        Guid userId, 
        Guid missionId, 
        CancellationToken ct = default);
    
    /// <summary>
    /// EN: Get tasks pending verification / VI: Lấy tasks đang chờ xác thực
    /// </summary>
    Task<IReadOnlyList<UserTask>> GetPendingVerificationAsync(CancellationToken ct = default);
}
