using SQLInsight.Core.Findings; namespace SQLInsight.Notifications; internal static class Texts { public static string Severity(Severity severity) => severity switch { Core.Findings.Severity.Critical => "Kritisk", Core.Findings.Severity.High => "Høj", Core.Findings.Severity.Medium => "Middel", Core.Findings.Severity.Low => "Lav", _ => "Info", }; public static string Headline(Notification n) => n.Kind switch { NotificationKind.FindingOpened => $"[{Severity(n.Severity)}] {n.Instance}: {n.Title}", NotificationKind.FindingResolved => $"[Løst] {n.Instance}: {n.Title}", NotificationKind.InstanceUnreachable => $"[Kan ikke nås] {n.Instance}", NotificationKind.InstanceRecovered => $"[Svarer igen] {n.Instance}", _ => n.Title, }; public static string Subject(IReadOnlyList batch) => batch.Count == 1 ? "SQLInsight: " + Headline(batch[0]) : $"SQLInsight: {batch.Count} hændelser på {string.Join(", ", batch.Select(n => n.Instance).Distinct())}"; public static string FirstSentence(string text) { var end = text.IndexOf(". ", StringComparison.Ordinal); return end < 0 ? text : text[..(end + 1)]; } }