feat: workout library read tools (get_workouts, get_workout) #4
Reference in New Issue
Block a user
Delete Branch "%!s()"
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?
Part of the 0.3.0 coaching-context milestone. Expose the reusable workout
library — distinct from the calendar events we already handle.
Tools
get_workouts—GET /athlete/{id}/workouts— list library workouts (optionally by folder)get_workout—GET /athlete/{id}/workouts/{id}— a single library workout's structureNotes
Implementation plan (0.3.0) — intended delivery model: Claude Opus 4.8
Branch:
feat/coaching-context; one conventionalfeat:commit for this issue.Endpoints (verified)
GET /athlete/{id}/workouts->Workout[]— no server-side folder filter (the path takes no query params), so any folder filtering is client-side via each workout'sfolder_id.GET /athlete/{id}/workouts/{workoutId}—workoutIdis an integer -> fullWorkoutincl.workout_doc.Workout schema (28 props, key ones to render)
id, name, description, type, sub_type, indoor, moving_time, distance, icu_training_load, icu_intensity, target, carbs_per_hour, folder_id, tags, workout_docNew module:
tools/workouts.pyget_workouts(folder_id: int | None = None, type: str | None = None)— list the library; optional client-side filters onfolder_id/type(documented as client-side). Compact per-row formatter: id, name, type, load, moving_time, folder_id.get_workout(workout_id: int)— full detail. Renderworkout_docsteps human-readably: reuse the step vocabulary documented inadd_or_update_event(power/hr/pace +%ftp/zones units, reps/nested steps, warmup/cooldown/freeride flags). Newformat_workout_detailsinutils/formatting.py; the existingformat_workouthelper is a good base but too thin — extend, don't fork.Notes
/folders/{id}/workoutsexplicitly deferred to a 0.4.0 issue.workout_doccan nest (reps+steps) — the renderer must recurse; cap depth defensively.Tests (
tests/test_workouts.py)workout_docrendering fixture, empty library, error dict, CredentialError. Coverage gate >=90%.Estimate
~300 LOC incl. tests.