Commit Graph

422 Commits

Author SHA1 Message Date
f312dd0dbb feat: Backend Phase 2 - Focus Areas API + Goals integration
All checks were successful
Deploy Development / deploy (push) Successful in 51s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 13s
**New Router: focus_areas.py**
- GET /focus-areas/definitions (list all, grouped by category)
- POST/PUT/DELETE /focus-areas/definitions (Admin CRUD)
- GET /focus-areas/user-preferences (legacy + future dynamic)
- PUT /focus-areas/user-preferences (auto-normalize to 100%)
- GET /focus-areas/stats (progress per focus area)

**Goals Router Extended:**
- FocusContribution model (focus_area_id + contribution_weight)
- GoalCreate/Update: focus_contributions field
- create_goal: Insert contributions after goal creation
- update_goal: Delete old + insert new contributions
- get_goals_grouped: Load focus_contributions per goal

**Main.py:**
- Registered focus_areas router

**Features:**
- Many-to-Many mapping (goals ↔ focus areas)
- Contribution weights (0-100%)
- Auto-mapped by Migration 031
- User can edit via UI (next: frontend)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-27 19:48:05 +01:00
2f64656d4d feat: Migration 031 - Focus Area System v2.0 (dynamic, extensible)
All checks were successful
Deploy Development / deploy (push) Successful in 56s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 15s
2026-03-27 19:44:18 +01:00
0a1da37197 fix: Remove g.direction from SELECT - column does not exist
All checks were successful
Deploy Development / deploy (push) Successful in 51s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 13s
2026-03-27 17:08:30 +01:00
495f218f9a feat: Add Goal Types admin link to Settings/AdminPanel
All checks were successful
Deploy Development / deploy (push) Successful in 51s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 14s
2026-03-27 17:05:42 +01:00
fac8820208 fix: SQL error - direction is in goals table, not goal_type_definitions
Some checks failed
Build Test / lint-backend (push) Waiting to run
Build Test / build-frontend (push) Waiting to run
Deploy Development / deploy (push) Has been cancelled
2026-03-27 17:05:14 +01:00
217990d417 fix: Prevent manual progress entries for automatic goals
All checks were successful
Deploy Development / deploy (push) Successful in 43s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 13s
**Backend Safeguards:**
- get_goals_grouped: Added source_table, source_column, direction to SELECT
- create_goal_progress: Check source_table before allowing manual entry
- Returns HTTP 400 if user tries to log progress for automatic goals (weight, activity, etc.)

**Prevents:**
- Data confusion: Manual entries in goal_progress_log for weight/activity/etc.
- Dual tracking: Same data in multiple tables
- User error: Wrong data entry location

**Result:**
- Frontend filter (!goal.source_table) now works correctly
- CustomGoalsPage shows ONLY custom goals (flexibility, strength, etc.)
- Clear error message if manual entry attempted via API

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-27 17:00:53 +01:00
1960ae4924 docs: Update CLAUDE.md - Custom Goals Page
All checks were successful
Deploy Development / deploy (push) Successful in 43s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 14s
2026-03-27 15:32:44 +01:00
bcb867da69 refactor: Separate goal tracking - strategic vs tactical
Some checks failed
Build Test / lint-backend (push) Waiting to run
Build Test / build-frontend (push) Waiting to run
Deploy Development / deploy (push) Has been cancelled
**UX Improvements:**
- Progress modal: full-width inputs, label-as-heading, left-aligned text
- Progress button only visible for custom goals (no source_table)
- Prevents confusion with automatic tracking (Weight, Activity, etc.)

**New Page: Custom Goals (Capture/Eigene Ziele):**
- Dedicated page for daily custom goal value entry
- Clean goal selection with progress bars
- Quick entry form (date, value, note)
- Recent progress history (last 5 entries)
- Mobile-optimized for daily use

**Architecture:**
- Analysis/Goals → Strategic (define goals, set priorities)
- Capture/Custom Goals → Tactical (daily value entry)
- History → Evaluation (goal achievement analysis)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-27 15:32:15 +01:00
398c645a98 feat: Goal Progress Log UI - complete frontend
All checks were successful
Deploy Development / deploy (push) Successful in 43s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 14s
- Added Progress button (TrendingUp icon) to each goal card
- Created Progress Modal with:
  • Form to add new progress entry (date, value, note)
  • Historical entries list with delete option
  • Category-colored goal info header
  • Auto-disables manual delete for non-manual entries
- Integration complete: handlers → API → backend

Completes Phase 0a Progress Tracking (Migration 030 + Backend + Frontend)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-27 14:02:24 +01:00
7db98a4fa6 feat: Goal Progress Log - backend + API (v2.1)
All checks were successful
Deploy Development / deploy (push) Successful in 44s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 13s
Implemented progress tracking system for all goals.

**Backend:**
- Migration 030: goal_progress_log table with unique constraint per day
- Trigger: Auto-update goal.current_value from latest progress
- Endpoints: GET/POST/DELETE /api/goals/{id}/progress
- Pydantic Models: GoalProgressCreate, GoalProgressUpdate

**Features:**
- Manual progress tracking for custom goals (flexibility, strength, etc.)
- Full history with date, value, note
- current_value always reflects latest progress entry
- One entry per day per goal (unique constraint)
- Cascade delete when goal is deleted

**API:**
- GET /api/goals/{goal_id}/progress - List all entries
- POST /api/goals/{goal_id}/progress - Log new progress
- DELETE /api/goals/{goal_id}/progress/{progress_id} - Delete entry

**Next:** Frontend UI (progress button, modal, history list)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-27 13:58:14 +01:00
ce37afb2bb fix: Migration 029 - activate missing goal types (flexibility, strength)
All checks were successful
Deploy Development / deploy (push) Successful in 43s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 13s
These goal types existed but were inactive or misconfigured.

Uses UPSERT (INSERT ... ON CONFLICT DO UPDATE):
- If exists → activate + fix labels/icons/category
- If not exists → create properly

Idempotent: Safe to run multiple times, works on dev + prod.

Both types have no automatic data source (source_table = NULL),
so current_value must be updated manually.

Fixes: flexibility and strength goals not visible in admin

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-27 13:53:47 +01:00
db90f397e8 feat: auto-assign goal category based on goal type
All checks were successful
Deploy Development / deploy (push) Successful in 49s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 14s
Added intelligent category assignment:
- Weight, body_fat, lean_mass → Körper
- Strength, flexibility → Training
- BP, VO2Max, RHR, HRV → Gesundheit
- Sleep goals → Erholung
- Nutrition goals → Ernährung
- Unknown types → Sonstiges

Changes:
1. getCategoryForGoalType() mapping function
2. Auto-set category in handleGoalTypeChange()
3. Auto-set category in handleCreateGoal()

User can still manually change category if needed.

Fixes: Blood pressure goals wrongly categorized as 'Training'

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-27 13:09:34 +01:00
498ad7a47f fix: show goal type label when name is empty
All checks were successful
Deploy Development / deploy (push) Successful in 49s
Build Test / lint-backend (push) Successful in 1s
Build Test / build-frontend (push) Successful in 13s
Enhanced fallback chain for goal display:
1. goal.name (custom name if set)
2. goal.label_de (from backend JOIN)
3. typeInfo.label_de (from goalTypesMap)
4. goal.goal_type (raw key as last resort)

Also use goal.icon from backend if available.

Fixes: Empty goal names showing blank in list

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-27 12:51:24 +01:00
9e95fd8416 fix: get_goals_grouped - remove is_active check (column doesn't exist)
All checks were successful
Deploy Development / deploy (push) Successful in 44s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 13s
goals table doesn't have is_active column.
Removed AND g.is_active = true from WHERE clause.

Fixes: psycopg2.errors.UndefinedColumn: column g.is_active does not exist

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-27 12:45:03 +01:00
ca4f722b47 fix: goal_utils - support different date column names
All checks were successful
Deploy Development / deploy (push) Successful in 45s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 13s
Fixed: column 'date' does not exist in blood_pressure_log

blood_pressure_log uses 'measured_at' instead of 'date'.
Added DATE_COLUMN_MAP for table-specific date columns:
- blood_pressure_log → measured_at
- fitness_tests → test_date
- all others → date

Replaced all hardcoded 'date' with dynamic date_col variable.

Fixes error: [ERROR] Failed to fetch value from blood_pressure_log.systolic

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-27 12:42:56 +01:00
1c00238414 fix: get_goals_grouped - remove non-existent linear_projection column
All checks were successful
Deploy Development / deploy (push) Successful in 52s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 15s
Fixed SQL error: column g.linear_projection does not exist
Replaced with: g.on_track, g.projection_date (actual columns)

This was causing Internal Server Error on /api/goals/grouped

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-27 12:41:06 +01:00
448d19b840 fix: Migration 028 - remove is_active from index (column doesn't exist yet)
All checks were successful
Deploy Development / deploy (push) Successful in 49s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 13s
Migration 028 failed because goals table doesn't have is_active column yet.
Removed WHERE clause from index definition.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-27 12:36:58 +01:00
caebc37da0 feat: goal categories UI - complete rebuild
All checks were successful
Deploy Development / deploy (push) Successful in 49s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 14s
Completed frontend for multi-dimensional goal priorities.

**UI Changes:**
- Category-grouped goal display with color-coded headers
- Each category shows: icon, name, description, goal count
- Priority stars (//) replace "PRIMÄR" badge
- Goals have category-colored left border
- Form fields: Category dropdown + Priority selector
- Removed "Gewichtung gesamt" display (useless UX)

**Categories:**
- 📉 Körper (body): Gewicht, Körperfett, Muskelmasse
- 🏋️ Training: Kraft, Frequenz, Performance
- 🍎 Ernährung: Kalorien, Makros, Essgewohnheiten
- 😴 Erholung: Schlaf, Regeneration, Ruhetage
- ❤️ Gesundheit: Vitalwerte, Blutdruck, HRV
- 📌 Sonstiges: Weitere Ziele

**Priority Levels:**
-  Hoch (1)
-  Mittel (2)
-  Niedrig (3)

**Implementation:**
- Load groupedGoals via api.listGoalsGrouped()
- GOAL_CATEGORIES + PRIORITY_LEVELS constants
- handleEditGoal/handleSaveGoal/handleCreateGoal extended
- Backward compatible (is_primary still exists)

Next: Test migration + UI, then update Dashboard to show top-1 per category

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-27 12:33:17 +01:00
6a3a782bff feat: goal categories and priorities - backend + API
Implemented multi-dimensional goal priorities (Option B).

**Backend Changes:**
- Migration 028: Added `category` + `priority` columns to goals table
- Auto-migration of existing goals to categories based on goal_type
- GoalCreate/GoalUpdate models extended with category + priority
- New endpoint: GET /api/goals/grouped (returns goals by category)
- Categories: body, training, nutrition, recovery, health, other
- Priorities: 1=high (), 2=medium (), 3=low ()

**API Changes:**
- Added api.listGoalsGrouped() binding

**Frontend (partial):**
- Added GOAL_CATEGORIES + PRIORITY_LEVELS constants
- Extended formData with category + priority fields
- Removed "Gewichtung gesamt" display (useless)
- Load groupedGoals in addition to flat goals list

Next: Complete frontend UI rebuild for category grouping

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-27 12:30:59 +01:00
2f51b26418 fix: focus areas slider NaN values and validation
All checks were successful
Deploy Development / deploy (push) Successful in 44s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 13s
Fixed multiple issues with relative weight sliders:
1. Sanitize focusData on load (ensure all 6 fields are numeric)
2. Sync focusTemp when clicking "Anpassen" button
3. Robust sum calculation filtering only *_pct fields
4. Convert NaN/undefined to 0 in all calculations
5. Safe Number() coercion before normalization

Fixes errors:
- "Gewichtung gesamt: NaN"
- "Input should be a valid integer, input: null"
- Prozent always showing 0%

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-27 12:20:01 +01:00
92cc309489 feat: relative weight sliders for focus areas
All checks were successful
Deploy Development / deploy (push) Successful in 44s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 13s
Improved UX for focus area configuration:
- Sliders now use relative weights (0-10) instead of percentages
- System automatically normalizes to percentages (sum=100%)
- Live preview shows "weight → percent%" (e.g., "5 → 50%")
- No more manual balancing required from user

User sets: Kraft=5, Ausdauer=3, Flexibilität=2
System calculates: 50%, 30%, 20%

Addresses user feedback: "Summe muss 100% sein" not user-friendly

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-27 12:10:56 +01:00
1fdf91cb50 fix: Migration 027 - health mode missing dimensions
All checks were successful
Deploy Development / deploy (push) Successful in 51s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 13s
Fixed health mode calculation to include all 6 dimensions.
Simplified CASE statements (single CASE instead of multiple additions).

Before: health mode only set flexibility (15%) + health (55%) = 70% 
After:  health mode sets all dimensions = 100% 
  - weight_loss: 5%
  - muscle_gain: 0%
  - strength: 10%
  - endurance: 20%
  - flexibility: 15%
  - health: 50%

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-27 10:56:53 +01:00
80d57918ae fix: Migration 027 constraint violation - health mode sum
All checks were successful
Deploy Development / deploy (push) Successful in 48s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 14s
Fixed health mode calculation in focus_areas migration.
Changed health_pct from 50 to 55 to ensure sum equals 100%.

Before: 0+0+10+20+15+50 = 95% (constraint violation)
After:  0+0+10+20+15+55 = 100% (valid)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-27 10:53:39 +01:00
d97925d5a1 feat: Focus Areas Slider UI (Goal System v2.0 complete)
All checks were successful
Deploy Development / deploy (push) Successful in 47s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 14s
Replaces single goal mode cards with weighted multi-focus system

UI Features:
- 6 sliders for focus dimensions (5% increments)
- Live sum calculation with visual feedback
- Validation: Sum must equal 100%
- Color-coded sliders per dimension
- Edit/Display mode toggle
- Shows derived values if not customized

UX Flow:
1. Default: Shows focus distribution (bars)
2. Click 'Anpassen': Shows sliders
3. Adjust percentages (sum = 100%)
4. Save → Updates backend + reloads

Visual:
- Active dimensions shown as colored cards (display mode)
- Gradient sliders with percentage labels (edit mode)
- Green box when sum = 100%, red when != 100%
- Info message if derived from old goal_mode

Complete v2.0:
 Backend (Migration 027, API, get_focus_weights V2)
 Frontend (Slider UI, state management, validation)
 Auto-migration (goal_mode → focus_areas)

Ready for: KI-Integration with weighted scoring
2026-03-27 10:36:42 +01:00
4a11d20c4d feat: Goal System v2.0 - Focus Areas with weighted priorities
All checks were successful
Deploy Development / deploy (push) Successful in 46s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 14s
BREAKING: Replaces single 'primary goal' with weighted multi-goal system

Migration 027:
- New table: focus_areas (6 dimensions with percentages)
- Constraint: Sum must equal 100%
- Auto-migration: goal_mode → focus_areas for existing users
- Unique constraint: One active focus_areas per profile

Backend:
- get_focus_weights() V2: Reads from focus_areas table
- Fallback: Uses goal_mode if focus_areas not set
- New endpoints: GET/PUT /api/goals/focus-areas
- Validation: Sum=100, range 0-100

API:
- getFocusAreas() - Get current weights
- updateFocusAreas(data) - Update weights (upsert)

Focus dimensions:
1. weight_loss_pct   (Fettabbau)
2. muscle_gain_pct   (Muskelaufbau)
3. strength_pct      (Kraftsteigerung)
4. endurance_pct     (Ausdauer)
5. flexibility_pct   (Beweglichkeit)
6. health_pct        (Allgemeine Gesundheit)

Benefits:
- Multiple goals with custom priorities
- More flexible than single primary goal
- KI can use weighted scores
- Ready for Phase 0b placeholder integration

UI: Coming in next commit (slider interface)
2026-03-27 08:38:03 +01:00
2303c04123 feat: filtered goal types - count specific training types
All checks were successful
Deploy Development / deploy (push) Successful in 49s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 14s
NEW FEATURE: Filter conditions for goal types
Enables counting/aggregating specific subsets of data.

Example use case: Count only strength training sessions per week
- Create goal type with filter: {"training_type": "strength"}
- count_7d now counts only strength training, not all activities

Implementation:
- Migration 026: filter_conditions JSONB column
- Backend: Dynamic WHERE clause building from JSON filters
- Supports single value: {"training_type": "strength"}
- Supports multiple values: {"training_type": ["strength", "hiit"]}
- Works with all 8 aggregation methods (count, avg, sum, min, max)
- Frontend: JSON textarea with example + validation
- Pydantic models: filter_conditions field added

Technical details:
- SQL injection safe (parameterized queries)
- Graceful degradation (invalid JSON ignored with warning)
- Backward compatible (NULL filters = no filtering)

Answers user question: 'Kann ich Trainingstypen wie Krafttraining separat zählen?'
Answer: YES! 🎯
2026-03-27 08:14:22 +01:00
2c978bf948 feat: dynamic schema dropdowns for goal type admin UI
All checks were successful
Deploy Development / deploy (push) Successful in 50s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 14s
Admin can now easily create custom goal types:
- New endpoint /api/goals/schema-info with table/column metadata
- 9 tables documented (weight, caliper, activity, nutrition, sleep, vitals, BP, rest_days, circumference)
- Table dropdown with descriptions (e.g., 'activity_log - Trainingseinheiten')
- Column dropdown dependent on selected table
- All columns documented in German with data types
- Fields optional (for complex calculation formulas)

UX improvements:
- No need to guess table/column names
- Clear descriptions for each field
- Type-safe selection (no typos)
- Cascading dropdowns (column depends on table)

Closes user feedback: 'Admin weiß nicht welche Tabellen/Spalten verfügbar sind'
2026-03-27 08:05:45 +01:00
210671059a debug: comprehensive error handling and logging for list_goals
All checks were successful
Deploy Development / deploy (push) Successful in 45s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 13s
- try-catch around entire endpoint
- try-catch for each goal progress update
- Detailed error logging with traceback
- Continue processing other goals if one fails
- Clear error message to frontend

This will show exact error location in logs.
2026-03-27 07:58:56 +01:00
1f4ee5021e fix: robust error handling in goal value fetcher
All checks were successful
Deploy Development / deploy (push) Successful in 44s
Build Test / lint-backend (push) Successful in 1s
Build Test / build-frontend (push) Successful in 13s
Prevents crashes when:
- Goal types have NULL source_table/column (lean_mass, inactive placeholders)
- Old goals reference inactive goal types
- SQL queries fail for any reason

Changes:
- Guard clause checks table/column before SQL
- try-catch wraps all aggregation queries
- Returns None gracefully instead of crashing endpoint
- Logs warnings for debugging

Fixes: Goals page not loading due to /api/goals/list crash
2026-03-27 07:55:19 +01:00
1e758696fd feat: Migration 025 - automatic cleanup and seed for goal_type_definitions
All checks were successful
Deploy Development / deploy (push) Successful in 46s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 14s
Fixes cases where Migration 024 partially ran:
- Removes created_by/updated_by columns if they exist
- Re-inserts seed data with ON CONFLICT DO NOTHING
- Fully automated, no manual intervention needed
- Production-safe (idempotent)

This ensures clean deployment to production without manual DB changes.
2026-03-27 07:49:09 +01:00
a039a0fad3 fix: Migration 024 - remove problematic FK constraints created_by/updated_by
Some checks failed
Build Test / lint-backend (push) Waiting to run
Build Test / build-frontend (push) Waiting to run
Deploy Development / deploy (push) Has been cancelled
Goal type definitions are global system entities, not user-specific.
System types seeded in migration cannot have created_by FK.

Changes:
- Remove created_by/updated_by columns from goal_type_definitions
- Update CREATE/UPDATE endpoints to not use these fields
- Migration now runs cleanly on container start
- No manual intervention needed for production deployment
2026-03-27 07:48:23 +01:00
b3cc588293 fix: make Migration 024 idempotent + add seed data fix script
All checks were successful
Deploy Development / deploy (push) Successful in 50s
Build Test / lint-backend (push) Successful in 1s
Build Test / build-frontend (push) Successful in 14s
2026-03-27 07:40:42 +01:00
c9e4b6aa02 debug: diagnostic script for Migration 024 state 2026-03-27 07:39:18 +01:00
8be87bfdfb fix: Remove broken table_exists check
All checks were successful
Deploy Development / deploy (push) Successful in 48s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 13s
Removed faulty EXISTS check that was causing "0" error.
Added debug logging and better error messages.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-27 07:34:29 +01:00
484c25575d feat: manual migration 024 runner script
All checks were successful
Deploy Development / deploy (push) Successful in 44s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 13s
Allows running Migration 024 manually if auto-migration failed.

Usage: python backend/run_migration_024.py

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-27 07:28:43 +01:00
bbee44ecdc fix: Better error handling for goal types loading
Some checks failed
Build Test / lint-backend (push) Waiting to run
Build Test / build-frontend (push) Waiting to run
Deploy Development / deploy (push) Has been cancelled
- Check if goal_type_definitions table exists
- Detailed error messages
- Fallback if goalTypes is empty
- Prevent form opening without types

Helps debugging Migration 024 issues.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-27 07:28:14 +01:00
043bed4323 docs: Phase 1.5 complete - update roadmap
All checks were successful
Deploy Development / deploy (push) Successful in 50s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 13s
Phase 1.5 (Flexible Goal System) erfolgreich abgeschlossen:
- 8h Aufwand (geplant 8-12h)
- Alle Tasks 
- System vollständig flexibel
- Phase 0b ready to start

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-27 06:52:18 +01:00
640ef81257 feat: Phase 1.5 - Flexible Goal System (DB-Registry) Part 2/2 - COMPLETE
Some checks failed
Build Test / lint-backend (push) Waiting to run
Build Test / build-frontend (push) Waiting to run
Deploy Development / deploy (push) Has been cancelled
Frontend dynamic goal types + Admin UI komplett implementiert.

Frontend GoalsPage:
- HARDCODED GOAL_TYPES entfernt
- Dynamic loading von goal_type_definitions via API
- goalTypes state + goalTypesMap für quick lookup
- Dropdown zeigt alle aktiven Types aus DB
- Vollständig flexibel - neue Types sofort verfügbar

Admin UI:
- AdminGoalTypesPage.jsx (400+ Zeilen)
  → Übersicht aller Goal Types (System + Custom)
  → Create/Edit/Delete Forms
  → CRUD via api.js (admin-only)
  → Validierung: System Types nur deaktivierbar, nicht löschbar
  → 8 Aggregationsmethoden im Dropdown
  → Category-Auswahl (body, mind, activity, nutrition, recovery, custom)
- Route registriert: /admin/goal-types
- Import in App.jsx

Phase 1.5 KOMPLETT:
 Migration 024 (goal_type_definitions)
 Universal Value Fetcher (goal_utils.py)
 CRUD API (goals.py)
 Frontend Dynamic Dropdown (GoalsPage.jsx)
 Admin UI (AdminGoalTypesPage.jsx)

System ist jetzt VOLLSTÄNDIG FLEXIBEL:
- Neue Goal Types via Admin UI ohne Code-Deploy
- Beispiele: Meditation, Trainingshäufigkeit, Planabweichung
- Phase 0b Platzhalter können alle Types nutzen
- Keine Doppelarbeit bei v2.0 Redesign

Nächster Schritt: Testing + Phase 0b (120+ Platzhalter)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-27 06:51:46 +01:00
65ee5f898f feat: Phase 1.5 - Flexible Goal System (DB-Registry) Part 1/2
All checks were successful
Deploy Development / deploy (push) Successful in 43s
Build Test / lint-backend (push) Successful in 1s
Build Test / build-frontend (push) Successful in 13s
KRITISCHE ARCHITEKTUR-ÄNDERUNG vor Phase 0b:
Ermöglicht dynamische Goal Types ohne Code-Änderungen.

Backend:
- Migration 024: goal_type_definitions Tabelle
  → 8 existierende Typen als Seed-Data migriert
  → Flexible Schema: source_table, aggregation_method, calculation_formula
  → System vs. Custom Types (is_system flag)
- goal_utils.py: Universal Value Fetcher
  → get_current_value_for_goal() ersetzt hardcoded if/elif chain
  → Unterstützt: latest, avg_7d, avg_30d, sum_30d, count_7d, etc.
  → Komplexe Formeln (lean_mass) via calculation_formula JSON
- goals.py: CRUD API für Goal Type Definitions
  → GET /goals/goal-types (public)
  → POST/PUT/DELETE /goals/goal-types (admin-only)
  → Schutz für System-Types (nicht löschbar)
- goals.py: _get_current_value_for_goal_type() delegiert zu Universal Fetcher

Frontend:
- api.js: 4 neue Funktionen (listGoalTypeDefinitions, create, update, delete)

Dokumentation:
- TODO_GOAL_SYSTEM.md: Phase 1.5 hinzugefügt, Roadmap aktualisiert

Part 2/2 (nächster Commit):
- Frontend: Dynamic Goal Types Dropdown
- Admin UI: Goal Type Management Page
- Testing

Warum JETZT (vor Phase 0b)?
- Phase 0b Platzhalter (120+) nutzen Goals für Score-Berechnungen
- Flexible Goals → automatisch in Platzhaltern verfügbar
- Später umbauen = Doppelarbeit (alle Platzhalter anpassen)

Zukünftige Custom Goals möglich:
- 🧘 Meditation (min/Tag)
- 📅 Trainingshäufigkeit (x/Woche)
- 📊 Planabweichung (%)
- 🎯 Ritual-Adherence (%)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-27 06:45:05 +01:00
27a8af7008 debug: Add logging and warnings for Goal System issues
All checks were successful
Deploy Development / deploy (push) Successful in 47s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 13s
Based on test feedback - 3 issues addressed:

1. Primary Toggle (Frontend Debug):
   - Add console.log in handleSaveGoal
   - Shows what data is sent to backend
   - Helps debug if checkbox state is correct

2. Lean Mass Display (Backend Debug):
   - Add error handling in lean_mass calculation
   - Log why calculation fails (missing weight/bf data)
   - Try-catch for value conversion errors

3. BP/Strength/Flexibility Warning (UI):
   - Yellow warning box for incomplete goal types
   - BP: "benötigt 2 Werte (geplant für v2.0)"
   - Strength/Flexibility: "Keine Datenquelle"
   - Transparent about limitations

Next: User re-tests with debug output to identify root cause.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-27 06:24:40 +01:00
14d80fc903 docs: zentrale TODO-Liste für Goal System erstellt
All checks were successful
Deploy Development / deploy (push) Successful in 51s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 13s
Tracking-Dokument für alle offenen Punkte:
- Phase 0b Tasks (120+ Platzhalter)
- v2.0 Redesign Probleme
- Gitea Issues Referenzen
- Timeline & Roadmap

Verhindert dass wichtige Punkte vergessen werden.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-27 06:17:57 +01:00
87464ff138 fix: Phase 1 - Goal System Quick Fixes + Abstraction Layer
All checks were successful
Deploy Development / deploy (push) Successful in 53s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 14s
Behebt 4 kritische Bugs in Phase 0a und schafft Basis für Phase 0b
ohne spätere Doppelarbeit.

Backend:
- NEW: goal_utils.py mit get_focus_weights() Abstraction Layer
  → V1: Mappt goal_mode zu Gewichten
  → V2 (später): Liest aus focus_areas Tabelle
  → Phase 0b Platzhalter (120+) müssen NICHT umgeschrieben werden
- FIX: Primary goal toggle in goals.py (is_primary im GoalUpdate Model)
  → Beim Update auf primary werden andere Goals korrekt auf false gesetzt
- FIX: lean_mass current_value Berechnung implementiert
  → weight - (weight * body_fat_pct / 100)
- FIX: VO2Max Spaltenname vo2_max (statt vo2max)
  → Internal Server Error behoben

CLAUDE.md:
- Version Update: Phase 1 Fixes (27.03.2026)

Keine Doppelarbeit:
- Alle zukünftigen Phase 0b Platzhalter nutzen get_focus_weights()
- v2.0 Redesign = nur eine Funktion ändern, nicht 120+ Platzhalter

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-27 06:13:47 +01:00
e3f1e399c2 docs: Goal System Redesign v2.0 - comprehensive concept
All checks were successful
Deploy Development / deploy (push) Successful in 46s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 14s
Created comprehensive redesign document addressing all identified issues:

Problems addressed:
1. Primary goal too simplistic → Weight system (0-100%)
2. Single goal mode too simple → Multi-mode with weights
3. Missing current values → All goal types with data sources
4. Abstract goal types → Concrete, measurable goals
5. Blood pressure single value → Compound goals (systolic/diastolic)
6. No user guidance → Norms, examples, age-specific values

New Concept:
- Focus Areas: Weighted distribution (30% weight loss + 25% endurance + ...)
- Goal Weights: Each goal has individual weight (not binary primary/not)
- Concrete Goal Types: cooper_test, pushups_max, squat_1rm, etc.
- Compound Goals: Support for multi-value targets (BP: 120/80)
- Guidance System: Age/gender-specific norms and examples

Schema Changes:
- New table: focus_areas (replaces single goal_mode)
- goals: Add goal_weight, target_value_secondary, current_value_secondary
- goals: Remove is_primary (replaced by weight)

UI/UX Redesign:
- Slider interface for focus areas (must sum to 100%)
- Goal editor with guidance and norms
- Weight indicators on all goals
- Special UI for compound goals

Implementation Phases: 16-21h total
- Phase 2: Backend Redesign (6-8h)
- Phase 3: Frontend Redesign (8-10h)
- Phase 4: Testing & Refinement (2-3h)

Status: WAITING FOR USER FEEDBACK & APPROVAL

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-26 22:05:05 +01:00
3dd10d3dc7 docs: Phase 0a completion - comprehensive documentation
All checks were successful
Deploy Development / deploy (push) Successful in 51s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 14s
CLAUDE.md:
- Version updated to v9e+ (Phase 0a Goal System Complete)
- Added Phase 0a feature section with full details
- Updated 'Letzte Updates' with Phase 0a completion
- Links to new documentation files

docs/issues/issue-50-phase-0a-goal-system.md (NEW):
- Complete Phase 0a implementation documentation
- Technical details: Migration 022, goals.py, GoalsPage
- 4 commits documented (337667f to 5be52bc)
- Lessons learned section
- Basis for Phase 0b documented
- Testing checklist + acceptance criteria

docs/NEXT_STEPS_2026-03-26.md (NEW):
- Comprehensive planning document
- Option A: Issue #49 - Prompt Page Assignment (6-8h)
- Option B: Phase 0b - Goal-Aware Placeholders (16-20h)
- Option C: Issue #47 - Value Table Refinement (4-6h)
- Recommendation: Szenario 1 (Quick Wins first)
- Detailed technical breakdown for both options
- Timeline estimates (4h/day vs 8h/day)
- 120+ placeholder categorization for Phase 0b

All documentation reflects current state post Phase 0a.
Next decision: Choose between Issue #49 or Phase 0b.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-26 21:49:07 +01:00
5be52bcfeb feat: goals navigation + UX improvements
All checks were successful
Deploy Development / deploy (push) Successful in 44s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 14s
Analysis Page:
- Add 'Ziele' button next to page title
- Direct navigation to /goals from analysis page
- Thematic link: goals influence AI analysis weighting

Goals Page:
- Fix text-align for text inputs (name, date, description)
- Text fields now left-aligned (numbers remain right-aligned)
- Better UX for non-numeric inputs

Navigation strategy: Goals accessible from Analysis page where
goal_mode directly impacts score calculation and interpretation.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-26 16:50:22 +01:00
75f0a5dd6e refactor: mobile-friendly goal form design
All checks were successful
Deploy Development / deploy (push) Successful in 46s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 13s
- Full-width inputs throughout the form
- Labels above inputs (mobile best practice)
- Section headers with emoji (🎯 Zielwert)
- Consistent spacing (marginBottom: 16)
- Read-only unit display as styled badge
- Primary goal checkbox in highlighted section
- Full-width buttons (btn-full class)
- Scrollable modal with top padding
- Error display above form

Matches VitalsPage design pattern for consistency.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-26 16:32:37 +01:00
906a3b7cdd fix: Migration 022 - remove invalid schema_migrations tracking
All checks were successful
Deploy Development / deploy (push) Successful in 47s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 13s
The migration system tracks migrations via filename automatically.
Removed manual DO block that used wrong column name (version vs filename).

Also removed unused json import from goals.py.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-26 16:26:48 +01:00
337667fc07 feat: Phase 0a - Minimal Goal System (Strategic + Tactical)
All checks were successful
Deploy Development / deploy (push) Successful in 51s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 14s
- Strategic Layer: Goal modes (weight_loss, strength, endurance, recomposition, health)
- Tactical Layer: Concrete goal targets with progress tracking
- Training phases (manual + auto-detection framework)
- Fitness tests (standardized performance tracking)

Backend:
- Migration 022: goal_mode in profiles, goals, training_phases, fitness_tests tables
- New router: routers/goals.py with full CRUD for goals, phases, tests
- API endpoints: /api/goals/* (mode, list, create, update, delete)

Frontend:
- GoalsPage: Goal mode selector + goal management UI
- Dashboard: Goals preview card with link
- API integration: goal mode, CRUD operations, progress calculation

Basis for 120+ placeholders and goal-aware analyses (Phase 0b)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-26 16:20:35 +01:00
ae93b9d428 docs: goal system priority analysis - hybrid approach
All checks were successful
Deploy Development / deploy (push) Successful in 47s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 14s
Key Decision: Minimal Goal System BEFORE Placeholders

Critical Finding:
- Same data = different interpretation per goal
- Example: -5kg FM, -2kg LBM
  - weight_loss: 78/100 (good!)
  - strength: 32/100 (LBM loss critical!)
  - Without goal: 50/100 (generic, wrong for both)

Recommended Approach (Hybrid):
1. Phase 0a (2-3h): Minimal Goal System
   - DB: goal_mode field
   - API: Get/Set Goal
   - UI: Goal Selector
   - Default: health

2. Phase 0b (16-20h): Goal-Aware Placeholders
   - 84 placeholders with goal-dependent calculations
   - Scores use goal_mode from day 1
   - No rework needed later

3. Phase 2+ (6-8h): Full Goal System
   - Goal recognition from patterns
   - Secondary goals
   - Goal progression tracking

Why Hybrid Works:
 Charts show correct interpretations immediately
 No rework of 84 placeholders later
 Goal recognition can come later (needs placeholders anyway)
 System is "smart coach" from day 1

File: docs/GOAL_SYSTEM_PRIORITY_ANALYSIS.md (650 lines)
2026-03-26 16:08:00 +01:00
8398368ed7 docs: comprehensive functional concept analysis
All checks were successful
Deploy Development / deploy (push) Successful in 44s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 14s
Analysis Results:
- 84 new placeholders needed from Fachkonzept
- Issues #26 & #27 too narrow (complementary, not conflicting)
- Recommend 4-phase approach: Placeholders → Charts → Rules → KI
- Transform: Data Collector → Active Coach

Key Findings:
- Fachkonzept defines 3 levels (Deskriptiv, Diagnostisch, Präskriptiv)
- 18 dedicated charts (K1-K5, E1-E5, A1-A8, C1-C6)
- Goal-mode dependent interpretation
- Lag-based correlations mandatory
- Confidence & data quality essential

Recommended Actions:
- Create Issues #52-55 (Baseline, Scores, Correlations, Metrics)
- Expand #26 & #27 based on Fachkonzept
- Start Phase 0: Implement 84 placeholders

File: docs/KONZEPT_ANALYSE_2026-03-26.md (385 lines)
2026-03-26 15:26:12 +01:00