using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Cleanuparr.Domain.Enums;
using Cleanuparr.Persistence.Models.Configuration.Arr;
namespace Cleanuparr.Persistence.Models.State;
///
/// Tracks arr command IDs returned from search requests so the SeekerCommandMonitor
/// can poll for completion status and inspect the download queue afterward.
///
public sealed record SeekerCommandTracker
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public Guid Id { get; set; } = Guid.NewGuid();
///
/// Foreign key to the arr instance this command was sent to
///
public Guid ArrInstanceId { get; set; }
///
/// Navigation property to the associated arr instance
///
public ArrInstance ArrInstance { get; set; } = null!;
///
/// The command ID returned by the arr API
///
public long CommandId { get; set; }
///
/// The AppEvent ID to update when the command completes
///
public Guid EventId { get; set; }
///
/// The external item ID that was searched (movieId or seriesId)
///
public long ExternalItemId { get; set; }
///
/// Display name of the item that was searched
///
public string ItemTitle { get; set; } = string.Empty;
///
/// The type of arr instance (Radarr, Sonarr, etc.)
///
public InstanceType ItemType { get; set; }
///
/// For Sonarr season-level searches, the season number that was searched.
/// 0 for Radarr or when not applicable.
///
public int SeasonNumber { get; set; }
///
/// When this tracker entry was created
///
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
///
/// Current status of the arr command
///
public SearchCommandStatus Status { get; set; } = SearchCommandStatus.Pending;
}