using ytLive.Models; namespace ytLive.Services; /// Report-by-exception (TASK 5 item 3): turns liveStreams /// configuration issues into a banner. good/ok/noData and info-only issues /// produce no banner; the first warning/error issue produces its text, colored /// by the worst severity (error beats warning). Pure — fully testable. public static class StreamHealthReporter { public static HealthIssueReport BannerFor(IEnumerable issues) { var reportable = issues .Where(i => i.Severity is StreamIssueSeverity.Warning or StreamIssueSeverity.Error) .ToList(); if (reportable.Count == 0) return new HealthIssueReport(null, false); var isError = reportable.Any(i => i.Severity == StreamIssueSeverity.Error); return new HealthIssueReport( string.Join(", ", reportable.Select(i => i.Type).Where(t => !string.IsNullOrWhiteSpace(t))), isError); } } /// null Text = no banner. IsError colors it: error → app red, else amber. public record HealthIssueReport(string? Text, bool IsError);