feat: flexible rest days system with JSONB config (v9d Phase 2a)
PROBLEM: Simple full_rest/active_recovery model doesn't support
context-specific rest days (e.g., strength rest but cardio allowed).
SOLUTION: JSONB-based flexible rest day configuration.
## Changes:
**Migration 010:**
- Refactor rest_days.type → rest_config JSONB
- Schema: {focus, rest_from[], allows[], intensity_max}
- Validation function with check constraint
- GIN index for performant JSONB queries
**Backend (routers/rest_days.py):**
- CRUD: list, create (upsert by date), get, update, delete
- Stats: count per week, focus distribution
- Validation: check activity conflicts with rest day config
**Frontend (api.js):**
- 7 new methods: listRestDays, createRestDay, updateRestDay,
deleteRestDay, getRestDaysStats, validateActivity
**Integration:**
- Router registered in main.py
- Ready for weekly planning validation rules
## Next Steps:
- Frontend UI (RestDaysPage with Quick/Custom mode)
- Activity conflict warnings
- Dashboard widget
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
0278a8e4a6
commit
b63d15fd02
4 files changed
+425
-2
No files matched your search
@@ -230,4 +230,13 @@ export const api = {
|
||||
fd.append('file', file)
|
||||
return req('/sleep/import/apple-health', {method:'POST', body:fd})
|
||||
},
|
||||
|
||||
// Rest Days (v9d Phase 2a)
|
||||
listRestDays: (l=90) => req(`/rest-days?limit=${l}`),
|
||||
createRestDay: (d) => req('/rest-days', json(d)),
|
||||
getRestDay: (id) => req(`/rest-days/${id}`),
|
||||
updateRestDay: (id,d) => req(`/rest-days/${id}`, jput(d)),
|
||||
deleteRestDay: (id) => req(`/rest-days/${id}`, {method:'DELETE'}),
|
||||
getRestDaysStats: (weeks=4) => req(`/rest-days/stats?weeks=${weeks}`),
|
||||
validateActivity: (date, activityType) => req('/rest-days/validate-activity', json({date, activity_type: activityType})),
|
||||
}
|
||||
Reference in new issue
Block a user