From d4c519c3b9935768a7481f83ee7cc717c25d3361 Mon Sep 17 00:00:00 2001 From: Robby Zambito Date: Fri, 8 Aug 2025 13:18:44 -0400 Subject: Update overall status based on incidents --- internal/api/handlers.go | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'internal') 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 + } + } } } }() -- cgit