Goals -System refactored - Platzhaltersystem enhanced (als draft) #53
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?
- Fixed unterminated string literal in get_placeholder_catalog() - Line 1037 had extra quote: ('quality_sessions_pct', 'Qualitätssessions (%)'),' - Should be: ('quality_sessions_pct', 'Qualitätssessions (%)'), Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>Bugs fixed based on actual error logs: 1. TypeError: progress_pct None handling - changed .get('progress_pct', 0) to (goal.get('progress_pct') or 0) 2. UUID Error: focus_area_id query - changed WHERE focus_area_id = %s to WHERE key = %s 3. NameError: calculate_recovery_score_v2 - added missing import in calculate_category_progress 4. UndefinedColumn: c_thigh_r - removed left/right separation, only c_thigh exists 5. UndefinedColumn: resting_heart_rate - fixed remaining AVG(resting_heart_rate) to AVG(resting_hr) 6. KeyError: total_sleep_min - changed dict access to duration_minutes Changes: - scores.py: Fixed progress_pct None handling, focus_area key query, added recovery import - body_metrics.py: Fixed thigh_28d_delta to use single c_thigh column - recovery_metrics.py: Fixed resting_hr SELECT queries, fixed sleep_debt dict access All errors from logs should now be resolved. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>Bug: Filtered goals by g.get('type_key') but goals table has 'goal_type' column. Result: weight_goals was always empty → _score_weight_trend returned None. Fix: Changed 'type_key' → 'goal_type' (matches goals table schema). Verified: Migration 022 defines goal_type column, not type_key. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>Fixed 2 critical placeholder issues: 1. focus_areas_weighted_json was empty: - Query used 'area_key' but column is 'key' in focus_area_definitions - Changed to SELECT key, not area_key 2. Goal progress placeholders showed "nicht verfügbar": - progress_pct in goals table is NULL (not auto-calculated) - Added manual calculation in all 3 formatter functions: * _format_goals_as_markdown() - shows % in table * _format_goals_behind() - finds lowest progress * _format_goals_on_track() - finds >= 50% progress All placeholders should now return proper values. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>**User Feedback:** "Macht es nicht Sinn, den nächsten verfügbaren Wert am oder nach dem Startdatum automatisch zu ermitteln und auch das Startdatum dann automatisch auf den Wert zu setzen?" **New Logic:** 1. User sets start_date: 2026-01-01 2. System finds FIRST measurement >= 2026-01-01 (e.g., 2026-01-15: 88 kg) 3. System auto-adjusts: - start_date → 2026-01-15 - start_value → 88 kg 4. User sees: "Start: 88 kg (15.01.26)" ✓ **Benefits:** - User doesn't need to know exact date of first measurement - More user-friendly UX - Automatically finds closest available data **Implementation:** - Changed query from "BETWEEN date ±7 days" to "WHERE date >= target_date" - Returns dict with {'value': float, 'date': date} - Both create_goal() and update_goal() now adjust start_date automatically Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>**Problem 1:** Edit form showed today's date instead of stored start_date - Cause: Fallback logic `goal.start_date || today` always defaulted to today - Fix: Load actual date or empty string (no fallback) - Input field: Remove fallback from value binding **Problem 2:** Timeline only showed target_date, not start_date - Added dedicated timeline display below values - Shows: "📅 15.01.26 → 31.05.26" - Only appears if at least one date exists - Start date with calendar icon, target date bold **Result:** - Editing goals now preserves the start_date ✓ - Timeline clearly shows start → target dates ✓ - No more accidental overwrites with today's date ✓ Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>OLD: Showed 3 goals with lowest progress % NEW: Calculates expected progress based on elapsed time vs. total time Shows goals with largest negative deviation (behind schedule) Example Weight Goal: - Total time: 98 days (22.02 - 31.05) - Elapsed: 34 days (35%) - Actual progress: 41% - Deviation: +7% (AHEAD, not behind) Also updated on_track to show goals with positive deviation (ahead of schedule). Note: Linear progress is a simplification. Real-world progress curves vary by goal type (weight loss, muscle gain, VO2max, etc). Future: AI-based projection models for more realistic expectations.Implements requested hybrid approach: WITH target_date: - Time-based deviation (actual vs. expected progress) - Format: 'Zielgewicht (41%, +7% voraus)' WITHOUT target_date: - Simple progress percentage - Format: 'Ruhepuls (100% erreicht)' or 'VO2max (0% erreicht)' Sorting: behind_schedule: 1. Goals with negative deviation (behind timeline) 2. Goals without date with progress < 50% on_track: 1. Goals with positive deviation (ahead of timeline) 2. Goals without date with progress >= 50% Kept debug logging for new hybrid logic validation.