using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Cleanuparr.Persistence.Models.Configuration.Arr;
namespace Cleanuparr.Persistence.Models.Configuration.Seeker;
///
/// Per-instance configuration for the Seeker job.
/// Links to an ArrInstance with cascade delete.
///
public sealed record SeekerInstanceConfig
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public Guid Id { get; set; } = Guid.NewGuid();
///
/// Foreign key to the arr instance this config belongs to
///
public Guid ArrInstanceId { get; set; }
///
/// Navigation property to the associated arr instance
///
public ArrInstance ArrInstance { get; set; } = null!;
///
/// Whether this instance is enabled for Seeker searches
///
public bool Enabled { get; set; } = true;
///
/// Arr tag IDs to exclude from search
///
public List SkipTags { get; set; } = [];
///
/// Timestamp of when this instance was last processed (for round-robin scheduling)
///
public DateTime? LastProcessedAt { get; set; }
///
/// The current cycle ID. All searches in the same cycle share this ID.
/// When all eligible items have been searched, a new ID is generated to start a fresh cycle.
///
public Guid CurrentCycleId { get; set; } = Guid.NewGuid();
///
/// Total number of eligible items in the library for this instance.
/// Updated each time the Seeker processes the instance.
///
public int TotalEligibleItems { get; set; }
///
/// Skip proactive search cycles when the number of actively downloading items
/// (SizeLeft > 0) in the arr queue is at or above this threshold. 0 = disabled.
///
public int ActiveDownloadLimit { get; set; } = 3;
///
/// Minimum number of days a cycle must span before a new one can start.
/// If a cycle completes faster, no searches are triggered until this time has elapsed.
///
public int MinCycleTimeDays { get; set; } = 7;
///
/// Only search monitored items during proactive searches
///
public bool MonitoredOnly { get; set; } = true;
///
/// Skip items that already meet their quality cutoff during proactive searches
///
public bool UseCutoff { get; set; }
///
/// Search items whose custom format score is below the quality profile's cutoff format score
///
public bool UseCustomFormatScore { get; set; }
}