feat: Update activity metrics handling to prioritize legacy columns over EAV
Deploy Development / deploy (push) Successful in 50s
Build Test / pytest-backend (push) Successful in 4s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 16s

- Enhanced the `merge_column_backed_and_eav_metrics` function to ensure that when both legacy columns and EAV values are present, the legacy column takes precedence.
- Revised documentation in `ACTIVITY_PRODUCTION_ARCHITECTURE_AND_PHASES.md` and `ACTIVITY_SCALAR_KANON_TABLE.md` to reflect the new reading logic and clarify the handling of metrics.
- Updated the `activity_data_canon.py` to specify the new merge behavior, ensuring consistency in data retrieval.
- Added unit tests to validate the new logic, confirming that legacy columns are preferred when available.
This commit is contained in:
Lars committed 2026-04-17 15:49:38 +02:00
1 parent 38797d687d
commit 680ecd1c06
6 files changed
+111 -23

No files matched your search

@@ -46,19 +46,19 @@ Schreibpfad: Universal-CSV und API sollen diese Keys auf **`activity_log`** mapp
`ACTIVITY_EAV_PRIMARY_PARAMETER_KEYS` in `activity_data_canon.py`. **`training_parameters.source_field`** = NULL (nach Kanon / Migration 057): kanonischer Speicher ist **`activity_session_metrics`**.
| Parameter-Key (`training_parameters.key`) | Legacy-Spalte `activity_log` (nur Lesefallback) | Kanonische Quelle | Lesefallback |
|-------------------------------------------|-------------------------------------------------|-------------------|--------------|
| `min_hr` | `hr_min` | **EAV** | Spalte, wenn EAV leer |
| `pace_min_per_km` | `pace_min_per_km` | **EAV** | Spalte, wenn EAV leer |
| `cadence` | `cadence` | **EAV** | Spalte, wenn EAV leer |
| `avg_power` | `avg_power` | **EAV** | Spalte, wenn EAV leer |
| `elevation_gain` | `elevation_gain` | **EAV** | Spalte, wenn EAV leer |
| `temperature_celsius` | `temperature_celsius` | **EAV** | Spalte, wenn EAV leer |
| `humidity_percent` | `humidity_percent` | **EAV** | Spalte, wenn EAV leer |
| `avg_hr_percent` | `avg_hr_percent` | **EAV** | Spalte, wenn EAV leer |
| `kcal_per_km` | `kcal_per_km` | **EAV** | Spalte, wenn EAV leer |
| Parameter-Key (`training_parameters.key`) | Legacy-Spalte `activity_log` | Schreib-Kanon (Ziel) |
|-------------------------------------------|------------------------------|------------------------|
| `min_hr` | `hr_min` | **EAV** |
| `pace_min_per_km` | `pace_min_per_km` | **EAV** |
| `cadence` | `cadence` | **EAV** |
| `avg_power` | `avg_power` | **EAV** |
| `elevation_gain` | `elevation_gain` | **EAV** |
| `temperature_celsius` | `temperature_celsius` | **EAV** |
| `humidity_percent` | `humidity_percent` | **EAV** |
| `avg_hr_percent` | `avg_hr_percent` | **EAV** |
| `kcal_per_km` | `kcal_per_km` | **EAV** |
Merge-Implementierung: `merge_column_backed_and_eav_metrics` in `activity_session_metrics.py`.
**Lesen:** `merge_column_backed_and_eav_metrics` — wenn Legacy-Spalte **und** EAV einen Wert haben, **gewinnt die Spalte** (kanonische `activity_log`-Sicht). EAV nur, wenn die Spalte leer/nicht koerzierbar ist.
---