- Shows first 10 errors with activity_id and error message
- Helps admin debug evaluation failures
- Errors shown in error box with details
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Shows first 10 errors with activity_id, training_type_id, and error message
- Helps debug evaluation failures
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- ProfileBuilder now renders inline below training type row
- Type editor form also inline (not at top of page)
- Both forms appear at item position with marginTop: 8
- User feedback: 'Die Position bleibt die ganze Zeit gleich!'
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
MAJOR UX IMPROVEMENT - No more JSON editing required!
New Component: ProfileBuilder.jsx
- Visual form for configuring training type profiles
- Parameter dropdown (dynamically loaded from API)
- Operator dropdown (>=, <=, >, <, =, ≠, between)
- Value input (type-aware, between shows min/max)
- Weight slider (1-10)
- Add/remove rules visually
- Pass strategy selection
- Optional checkbox per rule
- Expandable sections
Integration: AdminTrainingTypesPage.jsx
- Added ProfileBuilder component
- ⚙️ Settings icon per training type
- Opens visual form when clicked
- ✓ Profil badge shows configured types
- Loads 16 parameters from API
- Save directly to training type
User Experience:
1. Go to /admin/training-types
2. Click ⚙️ icon on any type
3. Visual form opens
4. Add rules via dropdowns
5. Save → Profile configured!
NO JSON EDITING NEEDED! 🎉
Next: Add visual builders for other dimensions (Zones, Effects, etc.)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Fixed "U.get is not a function" error:
- Added missing API methods to api.js:
- getProfileStats()
- getProfileTemplates()
- applyProfileTemplate()
- getTrainingParameters()
- batchEvaluateActivities()
- Updated AdminTrainingProfiles.jsx to use correct methods
- Replaced api.get/post/put with specific named methods
Error resolved. Page should now load correctly.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
New admin page for profile configuration:
- AdminTrainingProfiles.jsx: Profile management interface
- Statistics dashboard (configured/unconfigured count)
- Training types list with profile status badges
- JSON-based profile editor (modal)
- One-click template application (Running, Meditation, Strength)
- Batch re-evaluation button for existing activities
- Link in AdminPanel under "Trainingstypen (v9d)"
Features:
- Apply templates with one click
- Edit profiles as JSON in modal
- Real-time validation
- Success/error messages
- Responsive layout
Route: /admin/training-profiles
Next: Test and iterate, then Phase 3 (User-UI for viewing results)
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>
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>
Problem: Backend crashed on startup due to evaluation import failure
Solution: Wrap evaluation_helper import in try/except
Changes:
- Import evaluation_helper with error handling
- Add EVALUATION_AVAILABLE flag
- All evaluation calls now check flag before executing
- System remains functional even if evaluation system unavailable
This prevents backend crashes if:
- Migrations haven't run yet
- Dependencies are missing
- Import errors occur
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Automatic 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>
Problem: Creating new training types via Admin UI resulted in
'Internal Server Error' because abilities dict was passed directly
to PostgreSQL JSONB column without Json() wrapper.
Solution:
- Import Json from psycopg2.extras
- Wrap abilities_json with Json() in INSERT
- Wrap data.abilities with Json() in UPDATE
Same issue as rest_days JSONB fix (commit 7d627cf).
Closes#13
- Add RestDaysWidget component showing today's rest days with icons & colors
- Integrate widget into Dashboard (above training distribution)
- Highlight current day in RestDaysPage (accent border + HEUTE badge)
- Fix: Improve error handling in api.js (parse JSON detail field)
Part of v9d Phase 2 (Vitals & Recovery)
Problem: User can create multiple rest days of same type per date
(e.g., 2x Mental Rest on 2026-03-23) - makes no sense.
Solution: UNIQUE constraint on (profile_id, date, focus)
## Migration 012:
- Add focus column (extracted from rest_config JSONB)
- Populate from existing data
- Add NOT NULL constraint
- Add CHECK constraint (valid focus values)
- Add UNIQUE constraint (profile_id, date, focus)
- Add index for performance
## Backend:
- Insert focus column alongside rest_config
- Handle UniqueViolation gracefully
- User-friendly error: "Du hast bereits einen Ruhetag 'Muskelregeneration' für 23.03."
## Benefits:
- DB-level enforcement (clean)
- Fast queries (no JSONB scan)
- Clear error messages
- Prevents: 2x muscle_recovery same day
- Allows: muscle_recovery + mental_rest same day ✓
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Migration 011 removed UNIQUE constraint (profile_id, date) to allow
multiple rest days per date, but INSERT still used ON CONFLICT.
Error: psycopg2.errors.InvalidColumnReference: there is no unique or
exclusion constraint matching the ON CONFLICT specification
Solution: Remove ON CONFLICT clause, use plain INSERT.
Multiple entries per date now allowed.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Error: psycopg2.ProgrammingError: can't adapt type 'dict'
Solution: Import psycopg2.extras.Json and wrap config_dict
Changes:
- Import Json from psycopg2.extras
- Wrap config_dict with Json() in INSERT
- Wrap config_dict with Json() in UPDATE
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Problem: Photos were always getting NULL date instead of form date,
causing frontend to fallback to created timestamp (today).
Root cause: FastAPI requires Form() wrapper for form fields when
mixing with File() parameters. Without it, the date parameter was
treated as query parameter and always received empty string.
Solution:
- Import Form from fastapi
- Change date parameter from str="" to str=Form("")
- Return photo_date instead of date in response (consistency)
Now photos correctly use the date from the upload form and can be
backdated when uploading later.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Problem:
- Photo upload with empty date parameter (date='')
- PostgreSQL rejects empty string for DATE field
- Error: "invalid input syntax for type date: ''"
- Occurred when saving circumference entry with only photo
Fix:
- Convert empty string to NULL before INSERT
- Check: date if date and date.strip() else None
- NULL is valid for optional date field
Test case:
- Circumference entry with only photo → should work now
- Photo without date → stored with date=NULL ✓
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Changes:
1. Added sleep entry to CaptureHub (between Activity and Guide)
- Icon: 🌙
- Label: "Schlaf"
- Sub: "Schlafdaten erfassen oder Apple Health importieren"
- Color: #7B68EE (purple)
- Route: /sleep
2. Removed sleep from main bottom navigation
- Nav link removed (was 6 items → now 5 items)
- Moon icon import removed (no longer used)
- Route /sleep remains active (Widget + CaptureHub links work)
3. Widget link unchanged
- SleepWidget.jsx still links to /sleep ✓
- Dashboard → Widget → /sleep works
Result:
- Consistent UX: All data entry under "Erfassen"
- Clean navigation: 5 main nav items (was 6)
- Sleep accessible via: Dashboard Widget or Erfassen → Schlaf
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Conceptual change: duration_minutes = actual sleep time (not time in bed)
Backend:
- Plausibility check: deep + rem + light = duration (awake separate)
- Import: duration = deep + rem + light (without awake)
- Updated error message: clarifies awake not counted
Frontend:
- Label: "Schlafdauer (reine Schlafzeit, Minuten)"
- Auto-calculate: bedtime-waketime minus awake_minutes
- Plausibility check: only validates sleep phases (not awake)
- Both NewEntry and Edit mode updated
Rationale:
- Standard in sleep tracking (Apple Health shows "Sleep", not "Time in Bed")
- Clearer semantics: duration = how long you slept
- awake_minutes tracked separately for analysis
- More intuitive for users
Example:
- Time in bed: 22:00 - 06:00 = 480 min (8h)
- Awake phases: 30 min
- Sleep duration: 450 min (7h 30min) ✓
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Problem: Segments crossing midnight were split into different nights
- 22:30-23:15 (21.03) → assigned to 21.03
- 00:30-02:45 (22.03) → assigned to 22.03
But both belong to the same night (21/22.03)!
Solution: Gap-based grouping
- Sort segments chronologically
- Group segments with gap < 2 hours
- Night date = wake_time.date() (last segment's end date)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Backend:
- New endpoint POST /api/sleep/import/apple-health
- Parses Apple Health sleep CSV format
- Maps German phase names (Kern→light, REM→rem, Tief→deep, Wach→awake)
- Aggregates segments by night (wake date)
- Stores raw segments in JSONB (sleep_segments)
- Does NOT overwrite manual entries (source='manual')
Frontend:
- Import button in SleepPage with file picker
- Progress indicator during import
- Success/error messages
- Auto-refresh after import
Documentation:
- Added architecture rules reference to CLAUDE.md
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Creates rest_days table for rest day tracking
- Creates vitals_log table for resting HR + HRV
- Creates weekly_goals table for training planning
- Extends profiles with hf_max and sleep_goal_minutes columns
- Extends activity_log with avg_hr and max_hr columns
- Fixes sleep_goal_minutes missing column error in stats endpoint
- Includes stats error handling in SleepWidget
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
If stats endpoint fails, page will still load with empty stats.
This prevents 500 errors from blocking the entire sleep page.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
PostgreSQL TIME type doesn't accept empty strings.
Converting empty bedtime/wake_time to None before INSERT/UPDATE.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Profile IDs are UUID type in the profiles table, not VARCHAR.
This was causing foreign key constraint error on migration.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add sleep_log table with JSONB sleep_segments (Migration 009)
- Add sleep router with CRUD + stats endpoints (7d avg, 14d debt, trend, phases)
- Add SleepPage with quick/detail entry forms and inline edit
- Add SleepWidget to Dashboard showing last night + 7d average
- Add sleep navigation entry with Moon icon
- Register sleep router in main.py
- Add 9 new API methods in api.js
Phase 2b complete - ready for testing on dev
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Successful production deployment confirmed (21.03.2026)
- Document complete learnable mapping system
- List all 4 migrations (004-007)
- Update roadmap: Phase 2 next
v9d Phase 1b complete:
- 29 training types
- DB-based learnable mapping system
- Apple Health import with German support
- Inline editing UX
- Auto-learning from bulk categorization
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Edit form now appears at the position of the item being edited
- No scrolling needed - stays at same location
- Matches ActivityPage inline editing behavior
- Visual indicator: Accent border when editing
- Create form still appears at top (separate from list)
Benefits:
- Better UX - no need to scroll to top
- Easier to find edited item after saving
- Consistent with rest of app
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Issue 1: Automatic training type mapping didn't work
- Root cause: Only English workout names were mapped
- Solution: Added 20+ German workout type mappings:
- "Traditionelles Krafttraining" → hypertrophy
- "Outdoor Spaziergang" → walk
- "Innenräume Spaziergang" → walk
- "Matrial Arts" → technique (handles typo)
- "Cardio Dance" → dance
- "Geist & Körper" → yoga
- Plus: Laufen, Gehen, Radfahren, Schwimmen, etc.
Issue 2: Reimporting CSV created duplicates without training types
- Root cause: Import always did INSERT with new UUID, no duplicate check
- Solution: Check if entry exists (profile_id + date + start_time)
- If exists: UPDATE with new data + training type mapping
- If new: INSERT as before
- Handles multiple workouts per day (different start times)
- "Skipped" count now includes updated entries
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Update status: Phase 1b complete on develop
- Document all 29 training types
- List all completed features
- Ready for testing and prod deployment
- Next: v9d Phase 2 (Ruhetage, Ruhepuls, HF-Zonen, Schlaf)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Load training categories in ActivityPage
- Display colored badge next to activity name in list view
- Badge shows category icon + name with category color
- Only shown if training_category is set
- Completes v9d Phase 1b
Ready for testing and production deployment.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
UX improvements based on user feedback:
1. Move TrainingTypeDistribution from ActivityPage to History page
- ActivityPage is for data entry, not visualization
- History (Verlauf) shows personal development/progress
- Chart now respects period selector (7/30/90/365 days)
2. Improve AdminTrainingTypesPage form styling
- All input fields now full width (100%)
- Labels changed from inline to headings above fields
- Textareas increased from 2 to 4 rows
- Added resize: vertical for textareas
- Increased gap between fields from 12px to 16px
- Follows style guide conventions
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Backend (v9d Phase 1b):
- Migration 006: Add abilities JSONB column + descriptions
- admin_training_types.py: Full CRUD endpoints for training types
- List, Get, Create, Update, Delete
- Abilities taxonomy endpoint (5 dimensions: koordinativ, konditionell, kognitiv, psychisch, taktisch)
- Validation: Cannot delete types in use
- Register admin_training_types router in main.py
Frontend:
- AdminTrainingTypesPage: Full CRUD UI
- Create/edit form with all fields (category, subcategory, names, icon, descriptions, sort_order)
- List grouped by category with color coding
- Delete with usage check
- Note about abilities mapping coming in v9f
- Add TrainingTypeDistribution to ActivityPage stats tab
- Add admin link in AdminPanel (v9d section)
- Update api.js with admin training types methods
Notes:
- Abilities mapping UI deferred to v9f (flexible prompt system)
- Placeholders (abilities column) in place for future AI analysis
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Migration 005: Add cardio subcategories (Gehen, Tanzen)
- Migration 005: Add new category "Geist & Meditation" with 4 subcategories
(Meditation, Atemarbeit, Achtsamkeit, Visualisierung)
- Update categories endpoint with mind category metadata
- Update Apple Health mapping: dance → dance, add meditation/mindfulness
- 6 new training types total
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add get_training_type_for_apple_health() mapping function (23 workout types)
- CSV import now automatically assigns training_type_id/category/subcategory
- New endpoint: GET /activity/uncategorized (grouped by activity_type)
- New endpoint: POST /activity/bulk-categorize (bulk update training types)
- New component: BulkCategorize with two-level dropdown selection
- ActivityPage: new "Kategorisieren" tab for existing activities
- Update CLAUDE.md: v9d Phase 1b progress
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Phase 1b - UI Integration:
===========================
ActivityPage:
- Replace old activity type dropdown with TrainingTypeSelect
- Add training_type_id, training_category, training_subcategory to form
- Two-level selection (category → subcategory)
Dashboard:
- Add TrainingTypeDistribution card (pie chart)
- Shows last 28 days activity distribution by type
- Conditional rendering (only if activities exist)
Still TODO:
- History: Add type badge display (next commit)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Training types system: ✅ deployed to dev
- Logout button: ✅ tested and working
- Migration 004: ✅ applied successfully (23 types)
- API endpoints: ✅ functional
Next: Phase 1b (UI integration)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Phase 1: Training Types Basis
=============================
Backend:
- Migration 004: training_types table + seed data (24 types)
- New router: /api/training-types (grouped, flat, categories)
- Extend activity_log: training_type_id, training_category, training_subcategory
- Extend ActivityEntry model: support training type fields
Frontend:
- TrainingTypeSelect component (two-level dropdown)
- TrainingTypeDistribution component (pie chart)
- API functions: listTrainingTypes, listTrainingTypesFlat, getTrainingCategories
Quick Win: Logout Button
========================
- Add LogOut icon button in app header
- Confirm dialog before logout
- Redirect to / after logout
- Hover effect: red color on hover
Not yet integrated:
- TrainingTypeSelect not yet in ActivityPage form
- TrainingTypeDistribution not yet in Dashboard
(will be added in next commit)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Mark v9c as deployed to production (21.03.2026)
- Add BUG-005 to BUG-008 (login/verify navigation fixes)
- Document TrialBanner mailto change (on develop)
- Mark v9d as in progress
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace subscription selection link with email contact for now.
Future: Central subscription system on jinkendo.de for all apps.
Button text:
- "Abo wählen" → "Abo anfragen"
- "Jetzt upgraden" → "Kontakt aufnehmen"
Opens mailto:mitai@jinkendo.de with pre-filled subject and body.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1. Parse JSON error responses to extract 'detail' field
Fixes: {"detail":"..."} shown as raw JSON instead of clean text
2. Redirect 'already_verified' to '/' instead of '/login'
Fixes: Users land on empty page when already logged in
3. Change button text: "Jetzt anmelden" → "Weiter zum Dashboard"
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>