fixing snitch and adaptive medication timing persistance and logic

This commit is contained in:
2026-02-17 18:52:35 -06:00
parent cf2b4be033
commit f826e511d5
4 changed files with 47 additions and 46 deletions

View File

@@ -3,6 +3,7 @@ api/routes/adaptive_meds.py - API endpoints for adaptive medication settings
"""
import logging
import uuid
import flask
import jwt
import os
@@ -103,16 +104,11 @@ def register(app):
}
try:
# Check if settings exist
existing = adaptive_meds.get_adaptive_settings(user_uuid)
if existing:
postgres.update(
"adaptive_med_settings", update_data, {"user_uuid": user_uuid}
)
else:
update_data["user_uuid"] = user_uuid
postgres.insert("adaptive_med_settings", update_data)
update_data["user_uuid"] = user_uuid
update_data.setdefault("id", str(uuid.uuid4()))
postgres.upsert(
"adaptive_med_settings", update_data, conflict_columns=["user_uuid"]
)
return flask.jsonify({"success": True}), 200
except Exception as e: