update picked data strucures

This commit is contained in:
Andreas Wrede
2026-04-10 09:18:38 -04:00
parent 2f72cf0118
commit a5f31c5cb5
2 changed files with 16 additions and 3 deletions
+11 -2
View File
@@ -120,8 +120,11 @@ class AlertState:
# Helper to sanitize numeric values for JSON (handle inf/nan)
def sanitize_value(val):
if isinstance(val, float) and (math.isinf(val) or math.isnan(val)):
return None
if isinstance(val, float):
if math.isinf(val):
return "overdue"
if math.isnan(val):
return None
return val
result = {
@@ -148,6 +151,12 @@ class AlertState:
return result
def __setstate__(self, state):
"""Restore from pickle, backfilling fields added after the pickle was written."""
self.__dict__.update(state)
if not hasattr(self, 'consecutive_count'):
self.consecutive_count = 0
def acknowledge(self):
"""Acknowledge this alert to stop reminder notifications."""
self.acknowledged = True