v9d Phase 2d: Vitals Module Refactoring (Baseline + Blood Pressure) #22
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "develop"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
�nderungen
Backend
Frontend
Fixes
Testing
?? Generated with Claude Code
## Implemented ### DB-Schema (Migrations) - Migration 013: training_parameters table (16 standard parameters) - Migration 014: training_types.profile + activity_log.evaluation columns - Performance metric calculations (avg_hr_percent, kcal_per_km) ### Backend - Rule Engine - RuleEvaluator: Generic rule evaluation with 9 operators - gte, lte, gt, lt, eq, neq, between, in, not_in - Weighted scoring system - Pass strategies: all_must_pass, weighted_score, at_least_n - IntensityZoneEvaluator: HR zone analysis - TrainingEffectsEvaluator: Abilities development ### Backend - Master Evaluator - TrainingProfileEvaluator: 7-dimensional evaluation 1. Minimum Requirements (Quality Gates) 2. Intensity Zones (HR zones) 3. Training Effects (Abilities) 4. Periodization (Frequency & Recovery) 5. Performance Indicators (KPIs) 6. Safety (Warnings) 7. AI Context (simplified for MVP) - evaluation_helper.py: Utilities for loading + saving - routers/evaluation.py: API endpoints - POST /api/evaluation/activity/{id} - POST /api/evaluation/batch - GET /api/evaluation/parameters ### Integration - main.py: Router registration ## TODO (Phase 1.2) - Auto-evaluation on activity INSERT/UPDATE - Admin-UI for profile editing - User-UI for results display ## Testing - ✅ Syntax checks passed - 🔲 Runtime testing pending (after auto-evaluation) Part of Issue #15 - Training Type Profiles SystemAutomatic evaluation on activity INSERT/UPDATE: - create_activity(): Evaluate after manual creation - update_activity(): Re-evaluate after manual update - import_activity_csv(): Evaluate after CSV import (INSERT + UPDATE) - bulk_categorize_activities(): Evaluate after bulk training type assignment All evaluation calls wrapped in try/except to prevent activity operations from failing if evaluation encounters an error. Only activities with training_type_id assigned are evaluated. Phase 1.2 complete ✅ ## Next Steps (Phase 2): Admin-UI for training type profile configuration Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>SQL Error: VALUES lists must all be the same length (line 130) Cause: kcal_per_km row was missing validation_rules JSONB value Fixed: Added validation_rules '{"min": 0, "max": 1000}'::jsonb All 16 parameter rows now have correct 10 columns: key, name_de, name_en, category, data_type, unit, source_field, validation_rules, description_de, description_en Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>Admin endpoints for profile configuration: - Extended TrainingTypeCreate/Update models with profile field - Added profile column to all SELECT queries - Profile templates for Running, Meditation, Strength Training - Template endpoints: list, get, apply - Profile stats endpoint (configured/unconfigured count) New file: profile_templates.py - TEMPLATE_RUNNING: Endurance-focused with HR zones - TEMPLATE_MEDITATION: Mental-focused (low HR ≤ instead of ≥) - TEMPLATE_STRENGTH: Strength-focused API Endpoints: - GET /api/admin/training-types/profiles/templates - GET /api/admin/training-types/profiles/templates/{key} - POST /api/admin/training-types/{id}/profile/apply-template - GET /api/admin/training-types/profiles/stats Next: Frontend Admin-UI (ProfileEditor component) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>Backend: - New router: vitals.py with CRUD endpoints - GET /api/vitals (list) - GET /api/vitals/by-date/{date} - POST /api/vitals (upsert) - PUT /api/vitals/{id} - DELETE /api/vitals/{id} - GET /api/vitals/stats (7d/30d averages, trends) - Registered in main.py Frontend: - VitalsPage.jsx with manual entry form - List with inline editing - Stats overview (averages, trend indicators) - Added to CaptureHub (❤️ icon) - Route /vitals in App.jsx API: - Added vitals methods to api.js v9d Phase 2d - Vitals tracking complete Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>- Import endpoints for Omron blood pressure CSV (German date format) - Import endpoints for Apple Health vitals CSV - Import UI tab in VitalsPage with drag & drop for both sources - German month mapping for Omron date parsing ("13 März 2026") - Upsert logic preserves manual entries (source != 'manual') - Import result feedback (inserted/updated/skipped/errors) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>**Backend (insights.py):** - Extended _get_profile_data() to fetch sleep, rest_days, vitals - Added template variables for Sleep Module: {{sleep_summary}}, {{sleep_detail}}, {{sleep_avg_duration}}, {{sleep_avg_quality}} - Added template variables for Rest Days: {{rest_days_summary}}, {{rest_days_count}}, {{rest_days_types}} - Added template variables for Vitals: {{vitals_summary}}, {{vitals_detail}}, {{vitals_avg_hr}}, {{vitals_avg_hrv}}, {{vitals_avg_bp}}, {{vitals_vo2_max}} **Frontend (Analysis.jsx):** - Added 12 new template variables to VARS list in PromptEditor - Enables AI prompt creation for Sleep, Rest Days, and Vitals analysis All modules now have AI evaluation support for future prompt creation. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>BREAKING CHANGE: vitals_log split into vitals_baseline + blood_pressure_log **Architektur-Änderung:** - Baseline-Vitals (langsam veränderlich, 1x täglich morgens) → vitals_baseline (RHR, HRV, VO2 Max, SpO2, Atemfrequenz) - Kontext-abhängige Vitals (mehrfach täglich, situativ) → blood_pressure_log (Blutdruck + Kontext-Tagging) **Migration 015:** - CREATE TABLE vitals_baseline (once daily, morning measurements) - CREATE TABLE blood_pressure_log (multiple daily, context-aware) - Migrate data from vitals_log → new tables - Rename vitals_log → vitals_log_backup_pre_015 (safety) - Prepared for future: glucose_log, temperature_log (commented) **Backend:** - NEW: routers/vitals_baseline.py (CRUD + Apple Health import) - NEW: routers/blood_pressure.py (CRUD + Omron import + context) - UPDATED: main.py (register new routers, remove old vitals) - UPDATED: insights.py (query new tables, split template vars) **Frontend:** - UPDATED: api.js (new endpoints für baseline + BP) - UPDATED: Analysis.jsx (add {{bp_summary}} variable) **Nächster Schritt:** - Frontend: VitalsPage.jsx refactoren (3 Tabs: Morgenmessung, Blutdruck, Import) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>