feat: Refactor activity data handling and improve CSV import logic
Deploy Development / deploy (push) Successful in 53s
Build Test / pytest-backend (push) Successful in 4s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 16s

- Updated `ACTIVITY_PRODUCTION_ARCHITECTURE_AND_PHASES.md` to clarify the derivation of `ACTIVITY_MODULE_REGISTRY_FIELD_KEYS` from `csv_parser.module_registry`.
- Enhanced `activity_data_canon.py` to eliminate hardcoded key lists, ensuring all registry fields are derived dynamically.
- Refactored the `_import_activity` function to remove redundant parameters and streamline the import process.
- Improved the `insert_activity_csv_minimal` function to handle metrics exclusively through `update_activity_columns`, preventing hardcoded values.
- Updated frontend components to manage editable activity log fields more effectively, ensuring proper handling of metrics during CSV imports.
- Added unit tests to validate the new logic and ensure consistency in activity session metrics handling.
This commit is contained in:
Lars committed 2026-04-16 10:35:08 +02:00
1 parent cd29c7d433
commit 5cda485458
9 files changed
+191 -135

No files matched your search

-13
View File
@@ -899,12 +899,6 @@ def _import_activity(
start_time=workout_start_t,
end_time=end_str or None,
activity_type=wtype,
duration_min=registry_updates.get("duration_min"),
kcal_active=registry_updates.get("kcal_active"),
kcal_resting=registry_updates.get("kcal_resting"),
hr_avg=registry_updates.get("hr_avg"),
hr_max=registry_updates.get("hr_max"),
distance_km=registry_updates.get("distance_km"),
training_type_id=training_type_id,
training_category=training_category,
training_subcategory=training_subcategory,
@@ -921,14 +915,7 @@ def _import_activity(
cur,
profile_id,
str(aid),
workout_date=iso,
training_type_id=training_type_id,
duration_min=registry_updates.get("duration_min"),
hr_avg=registry_updates.get("hr_avg"),
hr_max=registry_updates.get("hr_max"),
distance_km=registry_updates.get("distance_km"),
kcal_active=registry_updates.get("kcal_active"),
kcal_resting=registry_updates.get("kcal_resting"),
)
upsert_session_metrics_from_csv_mapped(
cur,