- Added new functions to build fitness dashboard visualizations, including weekly training volume and training type distribution charts. - Updated the `charts.py` router to include a new endpoint for the fitness dashboard, integrating data from activity metrics. - Refactored existing activity-related functions to improve modularity and maintainability. - Updated frontend components to reflect the new fitness terminology and integrate the fitness dashboard overview, enhancing user experience.
55 lines
2.3 KiB
Markdown
55 lines
2.3 KiB
Markdown
# Fitness-Dashboard (Layer 2b) – Abnahme & technische Zuordnung
|
||
|
||
**Status:** umgesetzt (Frontend + Backend)
|
||
**Bezug:** Issue #53 (Phase 0c) – Layer 1 → Layer 2b Bundle → UI nur Darstellung
|
||
**Stand:** 2026-04-19
|
||
|
||
---
|
||
|
||
## Ziel
|
||
|
||
- Eine **Fitness-Übersicht** auf `/activity` (Capture-Hub: „Fitness“), die **keine parallelen Berechnungen** im Client führt.
|
||
- **Single Source of Truth:** `data_layer/activity_metrics` (und Scores/Focus wie bei den Platzhaltern), identische Chart-Payloads wie die bestehenden Chart-Endpunkte A1/A2.
|
||
|
||
---
|
||
|
||
## Backend
|
||
|
||
| Bestandteil | Pfad / Endpoint |
|
||
|-------------|-----------------|
|
||
| Chart-Payloads (A1/A2) | `build_training_volume_chart_payload`, `build_training_type_distribution_chart_payload` in `backend/data_layer/activity_metrics.py` |
|
||
| KPI-Kacheln (Struktur für UI) | `backend/data_layer/fitness_interpretation.py` → `build_fitness_dashboard_kpi_tiles` |
|
||
| Bundle | `backend/data_layer/fitness_viz.py` → `get_fitness_dashboard_viz_bundle(profile_id, days)` |
|
||
| API | `GET /api/charts/fitness-dashboard-viz?days=7…9999` in `backend/routers/charts.py` |
|
||
|
||
**Hinweise:**
|
||
|
||
- `days >= 9999` wählt eine **lange Historie** für die Zusammenfassung (analog Ernährungs-Bundle).
|
||
- `calculate_quality_sessions_pct(profile_id, days)` unterstützt ein variables Fenster (wird auch vom Quality-Chart genutzt).
|
||
|
||
---
|
||
|
||
## Frontend
|
||
|
||
| Bestandteil | Pfad |
|
||
|-------------|------|
|
||
| API-Client | `getFitnessDashboardViz(days)` in `frontend/src/utils/api.js` |
|
||
| Darstellung | `frontend/src/components/FitnessDashboardOverview.jsx` |
|
||
| Einbindung | `frontend/src/pages/ActivityPage.jsx` (oben, vor Tabs) |
|
||
| Navigation Capture | `frontend/src/config/captureNav.js` – Label **Fitness**, Route `/activity` |
|
||
|
||
---
|
||
|
||
## Erweiterungen (optional)
|
||
|
||
- Weitere Charts aus A3–A8 ins Bundle ziehen (weiterhin nur Payload-Referenz, keine Duplikat-Logik im Router).
|
||
- Gitea-Issue anlegen/verknüpfen, falls formale Nachverfolgung gewünscht.
|
||
|
||
---
|
||
|
||
## Abnahme-Checkliste
|
||
|
||
- [x] Bundle liefert `has_activity_entries`, `summary`, `kpi_tiles`, `charts.training_volume`, `charts.training_type_distribution`, `meta`.
|
||
- [x] Keine clientseitige Neuberechnung der KPIs aus Rohlisten.
|
||
- [x] `/api/charts/training-volume` und `/training-type-distribution` nutzen dieselben Builder wie das Bundle.
|