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; }
///
/// 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 library-level item that was searched (seriesId, movieId, albumId or bookId)
///
public long ExternalItemId { get; set; }
///
/// For Sonarr episode-level searches, the episode that was searched.
/// 0 when the search targeted a whole season, movie, album or book.
///
public long EpisodeId { get; set; }
///
/// Display name of the item that was searched
///
public string ItemTitle { get; set; } = string.Empty;
///
/// 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 DateTimeOffset CreatedAt { get; set; } = DateTimeOffset.UtcNow;
///
/// Current status of the arr command
///
public SearchCommandStatus Status { get; set; } = SearchCommandStatus.Pending;
}