feat: activity search + per-activity analytics tools #3
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. Richer activity access than the
current date-range
get_activities.Tools
search_activities—GET /athlete/{id}/activities/search— query by name/type/filtersget_activity_best_efforts—GET /activity/{id}/best-efforts— PRs/bests in an activityget_activity_interval_stats—GET /activity/{id}/interval-stats— deeper per-interval analyticsNotes
tools/activities.py. Register + tests.Implementation plan (0.3.0) — intended delivery model: Claude Opus 4.8
Branch:
feat/coaching-context; one conventionalfeat:commit for this issue.Endpoints (verified against the official OpenAPI spec — note the REQUIRED params)
GET /athlete/{id}/activities/search— queryq(required),limit(int) ->ActivitySearchResult[](id, name, start_date_local, type, race, distance, moving_time, tags, description)GET /activity/{id}/best-efforts— querystream(required, e.g.watts/hr/pace), optionalduration,distance,count,minValue,excludeIntervals,startIndex,endIndex->BestEfforts{efforts}GET /activity/{id}/interval-stats— querystart_index+end_index(both required) -> a singleIntervalobject. This computes stats for an arbitrary stream index range; it is NOT a per-interval list (that's the existingget_activity_intervals).Tools (extend
tools/activities.py)search_activities(query: str, limit: int = 20)— validate non-empty query; compact one-line-per-result formatter (date, type, name, distance, moving_time, id) — results feed other tools by id.get_activity_best_efforts(activity_id, stream = "watts", duration = None, distance = None, count = None)— pass through only non-None params; format each effort (duration/distance, value, start index).get_activity_interval_stats(activity_id, start_index: int, end_index: int)— docstring must explain the indices come from streams/intervals output; render via a trimmed variant of the existing interval formatting inutils/formatting.py(reuseformat_intervals' field set for a single interval).Conventions
Same as the rest of the repo: creds resolve, single HTTP path, error-shape check, formatted
strreturn, registration inserver.py+tools/__init__.py, formatters inutils/formatting.py.Tests (extend
tests/test_activities.pyor newtests/test_activity_analytics.py)qreturns a validation message, not an API call).Estimate
~300 LOC incl. tests. No new module needed.