fix: update SQL query in recovery chart payloads for accurate date filtering
All checks were successful
Deploy Development / deploy (push) Successful in 51s
Build Test / pytest-backend (push) Successful in 4s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 16s

- Modified the SQL query in `build_vital_signs_matrix_chart_payload` to use `measured_at::date` for date comparisons, ensuring correct data retrieval based on the measurement date.
- Adjusted the order of results to sort by `measured_at` instead of `date`, improving the accuracy of the latest vital signs data fetched.
This commit is contained in:
Lars 2026-04-20 08:24:23 +02:00
parent 33b08a8d82
commit d3cb9d4ad9

View File

@ -377,8 +377,8 @@ def build_vital_signs_matrix_chart_payload(profile_id: str, days: int) -> Dict[s
cur.execute( cur.execute(
"""SELECT systolic, diastolic """SELECT systolic, diastolic
FROM blood_pressure_log FROM blood_pressure_log
WHERE profile_id=%s AND date >= %s WHERE profile_id=%s AND measured_at::date >= %s::date
ORDER BY date DESC, time DESC ORDER BY measured_at DESC
LIMIT 1""", LIMIT 1""",
(profile_id, cutoff), (profile_id, cutoff),
) )