Skip to content

Commit 97df48f

Browse files
committed
Only use last heartbeat to determine server status
1 parent 261ab5d commit 97df48f

2 files changed

Lines changed: 7 additions & 8 deletions

File tree

RefreshDiscordBot/Api/UptimeKuma/StatusType.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ public enum StatusType : byte
66
Up = 1,
77
Pending = 2,
88
Maintenance = 3,
9+
Unknown = 255,
910
}

RefreshDiscordBot/Modules/ServerStatusModule.cs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,17 @@ public override async Task<string> GetString(CancellationToken ct)
2424

2525
if (heartbeat == null)
2626
return "Unknown";
27-
28-
StatusType status = StatusType.Pending;
2927

3028
List<List<HeartbeatList>> lists = heartbeat.HeartbeatList.Values.ToList();
31-
if (lists.All(l => l.All(h => h.Status is StatusType.Up or StatusType.Pending)))
29+
if (lists.All(l => (l.LastOrDefault()?.Status ?? StatusType.Unknown) is StatusType.Up or StatusType.Pending))
3230
return "OK";
3331

34-
if (lists.Any(l => l.Any(h => h.Status == StatusType.Maintenance)))
35-
return "Maintenance";
32+
if (lists.Any(l => (l.LastOrDefault()?.Status ?? StatusType.Unknown) == StatusType.Maintenance))
33+
return "🔧 Under Maintenance";
3634

37-
if (lists.All(l => l.All(h => h.Status == StatusType.Down)))
38-
return "Down";
35+
if (lists.All(l => (l.LastOrDefault()?.Status ?? StatusType.Unknown) == StatusType.Down))
36+
return "Down";
3937

40-
return "Degraded";
38+
return "⚠️ Degraded";
4139
}
4240
}

0 commit comments

Comments
 (0)