diff options
| author | Christian Cleberg <[email protected]> | 2026-04-11 23:36:35 -0500 |
|---|---|---|
| committer | Christian Cleberg <[email protected]> | 2026-04-11 23:36:35 -0500 |
| commit | 00cc231e9b419d27b412036d93457c2cbabe0b16 (patch) | |
| tree | 6b042b802fcddcd1e03f1ae0f666965620225485 /Hutch/Models | |
| parent | 0fde7529ceaebf1cd9baa01826d95d587023d001 (diff) | |
| download | hutch-00cc231e9b419d27b412036d93457c2cbabe0b16.tar.gz hutch-00cc231e9b419d27b412036d93457c2cbabe0b16.tar.bz2 hutch-00cc231e9b419d27b412036d93457c2cbabe0b16.zip | |
Add SourceHut system status screen and home disruption banner
Diffstat (limited to 'Hutch/Models')
| -rw-r--r-- | Hutch/Models/SystemStatusModels.swift | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/Hutch/Models/SystemStatusModels.swift b/Hutch/Models/SystemStatusModels.swift new file mode 100644 index 0000000..9a664b0 --- /dev/null +++ b/Hutch/Models/SystemStatusModels.swift @@ -0,0 +1,84 @@ +import Foundation + +enum StatusLevel: String, Codable, Sendable { + case operational + case degraded + case majorOutage + case maintenance + case unknown + + var displayName: String { + switch self { + case .operational: + "Operational" + case .degraded: + "Degraded" + case .majorOutage: + "Major outage" + case .maintenance: + "Maintenance" + case .unknown: + "Unknown" + } + } + + var requiresAttention: Bool { + switch self { + case .degraded, .majorOutage, .maintenance: + true + case .operational, .unknown: + false + } + } +} + +struct StatusServiceState: Identifiable, Hashable, Codable, Sendable { + let id: String + let name: String + let slug: String? + let status: StatusLevel + let description: String? +} + +struct StatusIncident: Identifiable, Hashable, Codable, Sendable { + let id: String + let title: String + let summary: String? + let url: URL? + let publishedAt: Date + let updatedAt: Date? + let isActive: Bool? +} + +struct SystemStatusSnapshot: Hashable, Codable, Sendable { + let services: [StatusServiceState] + let activeIncidents: [StatusIncident] + let lastUpdated: Date + + var disruptedServices: [StatusServiceState] { + services.filter { $0.status.requiresAttention } + } + + var hasDisruption: Bool { + !disruptedServices.isEmpty + } + + var overallStatusText: String { + hasDisruption ? "Experiencing disruptions" : "All monitored services operational" + } + + var bannerSummary: String { + if disruptedServices.count == 1, let service = disruptedServices.first { + return "\(service.name) disrupted" + } + if disruptedServices.count > 1 { + return "\(disruptedServices.count) services disrupted" + } + return "SourceHut service disruption" + } +} + +struct SystemStatusPageData: Sendable { + let snapshot: SystemStatusSnapshot + let recentIncidents: [StatusIncident] +} |
