fixing snitch and adaptive medication timing persistance and logic
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
api/routes/snitch.py - API endpoints for snitch system
|
||||
"""
|
||||
|
||||
import uuid
|
||||
import flask
|
||||
import jwt
|
||||
import os
|
||||
@@ -89,15 +90,10 @@ def register(app):
|
||||
"updated_at": datetime.utcnow(),
|
||||
}
|
||||
|
||||
# Check if settings exist
|
||||
existing = snitch_core.get_snitch_settings(user_uuid)
|
||||
|
||||
if existing:
|
||||
postgres.update("snitch_settings", update_data, {"user_uuid": user_uuid})
|
||||
else:
|
||||
update_data["user_uuid"] = user_uuid
|
||||
update_data["created_at"] = datetime.utcnow()
|
||||
postgres.insert("snitch_settings", update_data)
|
||||
update_data["user_uuid"] = user_uuid
|
||||
update_data.setdefault("id", str(uuid.uuid4()))
|
||||
update_data.setdefault("created_at", datetime.utcnow())
|
||||
postgres.upsert("snitch_settings", update_data, conflict_columns=["user_uuid"])
|
||||
|
||||
return flask.jsonify({"success": True}), 200
|
||||
|
||||
@@ -161,6 +157,7 @@ def register(app):
|
||||
), 400
|
||||
|
||||
contact_data = {
|
||||
"id": str(uuid.uuid4()),
|
||||
"user_uuid": user_uuid,
|
||||
"contact_name": data["contact_name"],
|
||||
"contact_type": data["contact_type"],
|
||||
@@ -277,6 +274,7 @@ def register(app):
|
||||
|
||||
# Insert into snitch_log so the bot will pick it up and send it
|
||||
log_data = {
|
||||
"id": str(uuid.uuid4()),
|
||||
"user_uuid": user_uuid,
|
||||
"contact_id": contact.get("id"),
|
||||
"medication_id": None, # Test snitch, no actual medication
|
||||
|
||||
Reference in New Issue
Block a user