1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
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]
}
|