using System.Text.Json.Serialization; namespace Cleanuparr.Infrastructure.Stats; /// /// Aggregated application statistics for dashboard integrations /// public class StatsResponse { /// /// Event statistics within the timeframe /// public EventStats Events { get; set; } = new(); /// /// Strike statistics within the timeframe /// public StrikeStats Strikes { get; set; } = new(); /// /// Job run statistics within the timeframe /// public JobStats Jobs { get; set; } = new(); /// /// Current health status of download clients and arr instances /// public HealthStats Health { get; set; } = new(); /// /// When this response was generated /// public DateTime GeneratedAt { get; set; } = DateTime.UtcNow; } /// /// Event statistics grouped by type and severity /// public class EventStats { /// /// Total number of events in the timeframe /// public int TotalCount { get; set; } /// /// Events grouped by EventType /// public Dictionary ByType { get; set; } = new(); /// /// Events grouped by severity level /// public Dictionary BySeverity { get; set; } = new(); /// /// The timeframe in hours that these stats cover /// public int TimeframeHours { get; set; } /// /// Recent event items (only included when includeEvents > 0) /// [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] public List? RecentItems { get; set; } } /// /// Strike statistics /// public class StrikeStats { /// /// Total number of strikes in the timeframe /// public int TotalCount { get; set; } /// /// Strikes grouped by StrikeType /// public Dictionary ByType { get; set; } = new(); /// /// Number of download items removed in the timeframe /// public int ItemsRemoved { get; set; } /// /// The timeframe in hours that these stats cover /// public int TimeframeHours { get; set; } /// /// Recent strike items (only included when includeStrikes > 0) /// [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] public List? RecentItems { get; set; } } /// /// Job run statistics /// public class JobStats { /// /// Job run stats grouped by JobType /// public Dictionary ByType { get; set; } = new(); /// /// The timeframe in hours that these stats cover /// public int TimeframeHours { get; set; } } /// /// Statistics for a specific job type /// public class JobTypeStats { /// /// Total number of runs in the timeframe /// public int TotalRuns { get; set; } /// /// Number of completed runs /// public int Completed { get; set; } /// /// Number of failed runs /// public int Failed { get; set; } /// /// When the last job of this type ran /// public DateTime? LastRunAt { get; set; } /// /// When this job is next scheduled to run /// public DateTime? NextRunAt { get; set; } } /// /// Health status summary for all clients and instances /// public class HealthStats { /// /// Health status of download clients /// public List DownloadClients { get; set; } = []; /// /// Health status of arr instances /// public List ArrInstances { get; set; } = []; } /// /// Health status DTO for a download client /// public class DownloadClientHealthDto { public Guid Id { get; set; } public string Name { get; set; } = string.Empty; public string Type { get; set; } = string.Empty; public bool IsHealthy { get; set; } public DateTime LastChecked { get; set; } public double? ResponseTimeMs { get; set; } public string? ErrorMessage { get; set; } } /// /// Health status DTO for an arr instance /// public class ArrInstanceHealthDto { public Guid Id { get; set; } public string Name { get; set; } = string.Empty; public string Type { get; set; } = string.Empty; public bool IsHealthy { get; set; } public DateTime LastChecked { get; set; } public string? ErrorMessage { get; set; } } /// /// Recent event DTO for stats endpoint /// public class RecentEventDto { public Guid Id { get; set; } public DateTime Timestamp { get; set; } public string EventType { get; set; } = string.Empty; public string Message { get; set; } = string.Empty; public string Severity { get; set; } = string.Empty; public string? Data { get; set; } } /// /// Recent strike DTO for stats endpoint /// public class RecentStrikeDto { public Guid Id { get; set; } public string Type { get; set; } = string.Empty; public DateTime CreatedAt { get; set; } public string DownloadId { get; set; } = string.Empty; public string Title { get; set; } = string.Empty; }