get_exercise_history
Retrieve historical workout data for a specific exercise to track progress over time. Filter by date range and set result limits to analyze performance trends.
Instructions
Get history of a specific exercise across workouts.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| exercise_name | Yes | ||
| from_date | No | ||
| to_date | No | ||
| limit | No |
Implementation Reference
- src/main.py:331-371 (handler)Implementation of the get_exercise_history tool which queries the database for exercise history based on exercise name and date range.
def get_exercise_history( exercise_name: str, from_date: Optional[str] = None, to_date: Optional[str] = None, limit: int = 20, ) -> dict[str, list[dict[str, Any]]]: """Get history of a specific exercise across workouts.""" conn = get_connection() cursor = conn.cursor() base = """ SELECT w.id as workout_id, w.date_time, w.workout_type, w.tags, w.notes as workout_notes, e.id as exercise_id, e.name as exercise_name, e.category as exercise_category, e.notes as exercise_notes FROM workouts w JOIN exercises e ON e.workout_id = w.id WHERE LOWER(e.name) = LOWER(?) """ params: list[Any] = [exercise_name] if from_date: base += " AND w.date_time >= ?" params.append(f"{_ensure_date(from_date)}T00:00:00") if to_date: base += " AND w.date_time <= ?" params.append(f"{_ensure_date(to_date)}T23:59:59") base += " ORDER BY w.date_time DESC LIMIT ?" params.append(limit) cursor.execute(base, params) rows = cursor.fetchall() entries: list[dict[str, Any]] = [] for row in rows: item = _row_to_dict(row) item["tags"] = deserialize_tags(item["tags"]) item["sets"] = _load_sets(conn, item["exercise_id"]) entries.append(item) conn.close() return {"entries": entries}