diff options
author | Robby Zambito <contact@robbyzambito.me> | 2025-08-08 13:18:44 -0400 |
---|---|---|
committer | Robby Zambito <contact@robbyzambito.me> | 2025-08-08 13:18:52 -0400 |
commit | d4c519c3b9935768a7481f83ee7cc717c25d3361 (patch) | |
tree | 6dc5606fdedc90e25482cab56d5e11317d5d0f9d /internal | |
parent | 9671b4abf936f59b9d04f9d26b301e65fa78753d (diff) |
Update overall status based on incidents
Diffstat (limited to 'internal')
-rw-r--r-- | internal/api/handlers.go | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/internal/api/handlers.go b/internal/api/handlers.go index 2cc2188..4c4b2ec 100644 --- a/internal/api/handlers.go +++ b/internal/api/handlers.go @@ -102,8 +102,8 @@ func InitializeAPI(logs *[LogLength]string, n *int, toLogParser chan string) { // ScheduledMaintenance: 0, // } status.overallStatus = overallStatus{ - Status: StatusDegraded, - Description: "Everything is not great", + Status: StatusOperational, + Description: "Everything is operating normally", Uptime: 50.0, ResponseTime: 20000, ActiveIncidents: 9001, @@ -207,6 +207,19 @@ func InitializeAPI(logs *[LogLength]string, n *int, toLogParser chan string) { addRotLog(logs, n, toLogParser, fmt.Sprintf(`{"incidentEvent": %s}`, string(jsonData))) }) status.overallStatus.ActiveIncidents = len(status.incidents) + + status.overallStatus.Status = StatusOperational + status.overallStatus.Description = "Everything is operating normally" + for _, s := range status.incidents { + if s.Status == StatusDown { + status.overallStatus.Status = StatusDown + break + } + + if s.Status == StatusDegraded { + status.overallStatus.Status = StatusDegraded + } + } } } }() |