fixed spamming i hope
This commit is contained in:
@@ -12,7 +12,7 @@ import json
|
||||
from datetime import datetime, timedelta, time
|
||||
from typing import Optional, Dict, List, Tuple
|
||||
import core.postgres as postgres
|
||||
from core.tz import user_now
|
||||
from core.tz import user_now, user_today_for
|
||||
|
||||
|
||||
def get_adaptive_settings(user_uuid: str) -> Optional[Dict]:
|
||||
@@ -249,12 +249,12 @@ def should_send_nag(
|
||||
if not presence.get("is_currently_online"):
|
||||
return False, "User offline"
|
||||
|
||||
# Get today's schedule record
|
||||
# Get today's schedule record for this specific time slot
|
||||
today = current_time.date()
|
||||
schedules = postgres.select(
|
||||
"medication_schedules",
|
||||
{"user_uuid": user_uuid, "medication_id": med_id, "adjustment_date": today},
|
||||
)
|
||||
query = {"user_uuid": user_uuid, "medication_id": med_id, "adjustment_date": today}
|
||||
if scheduled_time is not None:
|
||||
query["adjusted_time"] = scheduled_time
|
||||
schedules = postgres.select("medication_schedules", query)
|
||||
|
||||
if not schedules:
|
||||
return False, "No schedule found"
|
||||
@@ -295,7 +295,7 @@ def should_send_nag(
|
||||
|
||||
def record_nag_sent(user_uuid: str, med_id: str, scheduled_time: str):
|
||||
"""Record that a nag was sent."""
|
||||
today = datetime.utcnow().date()
|
||||
today = user_today_for(user_uuid)
|
||||
|
||||
schedules = postgres.select(
|
||||
"medication_schedules",
|
||||
@@ -315,7 +315,7 @@ def record_nag_sent(user_uuid: str, med_id: str, scheduled_time: str):
|
||||
|
||||
def create_daily_schedule(user_uuid: str, med_id: str, base_times: List[str]):
|
||||
"""Create today's medication schedule with adaptive adjustments."""
|
||||
today = datetime.utcnow().date()
|
||||
today = user_today_for(user_uuid)
|
||||
|
||||
# Check if schedule already exists
|
||||
existing = postgres.select(
|
||||
@@ -346,7 +346,7 @@ def create_daily_schedule(user_uuid: str, med_id: str, base_times: List[str]):
|
||||
|
||||
def mark_med_taken(user_uuid: str, med_id: str, scheduled_time: str):
|
||||
"""Mark a medication as taken."""
|
||||
today = datetime.utcnow().date()
|
||||
today = user_today_for(user_uuid)
|
||||
|
||||
postgres.update(
|
||||
"medication_schedules",
|
||||
|
||||
Reference in New Issue
Block a user