fixing snitch and adaptive medication timing persistance and logic
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user