opus pass 2

This commit is contained in:
2026-02-17 00:30:05 -06:00
parent 123a7ce3e7
commit d673d73530

View File

@@ -67,7 +67,8 @@ def record_presence_event(user_uuid: str, event_type: str, timestamp: datetime):
if not presence:
return
history = json.loads(presence.get("presence_history", "[]"))
raw_history = presence.get("presence_history", [])
history = json.loads(raw_history) if isinstance(raw_history, str) else raw_history
# Add new event
history.append({"type": event_type, "timestamp": timestamp.isoformat()})
@@ -88,7 +89,8 @@ def calculate_typical_wake_time(user_uuid: str) -> Optional[time]:
if not presence:
return None
history = json.loads(presence.get("presence_history", "[]"))
raw_history = presence.get("presence_history", [])
history = json.loads(raw_history) if isinstance(raw_history, str) else raw_history
if len(history) < 3:
return None