feat(schema, csv_parser): Update activity log schema and parsing logic
Deploy Development / deploy (push) Successful in 48s
Build Test / pytest-backend (push) Successful in 3s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 16s

- Increased precision for `kcal_active`, `kcal_resting`, `hr_avg`, and `hr_max` fields in the activity log schema.
- Added a new function `_activity_hr_bpm` to validate heart rate values during CSV import, ensuring they fall within plausible ranges.
- Updated the CSV parser to utilize the new heart rate validation function for improved data integrity.
- Enhanced the type converter to accommodate additional aliases for energy fields in CSV imports.
- Added a test to verify conversion of active energy from kJ to kcal, ensuring accurate data handling.
This commit is contained in:
Lars committed 2026-04-11 06:41:23 +02:00
1 parent 08a2485f43
commit 6945b748cb
7 files changed
+70 -11

No files matched your search

+12
View File
@@ -266,6 +266,18 @@ def test_iso_yyyy_mm_dd_dateutil_fallback_not_dayfirst_swapped():
assert d.month == 4 and d.day == 9
def test_activity_kcal_active_kj_source_unit_to_kcal():
"""Apple-DE: Aktive Energie als kJ; DB-Feld ist kcal."""
spec = {
"type": "float",
"decimal_separator": ".",
"flexible": True,
"source_unit": "kj",
}
v = convert_value("4184", "kcal_active", spec, module="activity")
assert abs(v - 1000.0) < 0.02
def test_source_unit_choices_include_custom_at_end():
opts = source_unit_choices_for_field("nutrition", "protein_g")
assert opts[-1]["id"] == "custom"