get_last_workout
Retrieve your most recent workout by specifying type or tag to track exercise history and monitor fitness progress.
Instructions
Get the most recent workout matching type or tag.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| workout_type | No | ||
| tag | No |
Implementation Reference
- src/main.py:293-327 (handler)The get_last_workout function is defined and decorated as an app.tool, acting as the handler for retrieving the most recent workout matching specified type or tags.
@app.tool() def get_last_workout( workout_type: Optional[str] = None, tag: Optional[str] = None, ) -> dict[str, Any | None]: """Get the most recent workout matching type or tag.""" if not workout_type and not tag: raise ValueError("At least one of workout_type or tag is required") conn = get_connection() cursor = conn.cursor() filters: list[str] = [] params: list[Any] = [] if workout_type: filters.append("workout_type = ?") params.append(workout_type) if tag: filters.append("tags LIKE ?") params.append(f'%"{tag}"%') base = "SELECT * FROM workouts" if filters: base += " WHERE " + " AND ".join(filters) base += " ORDER BY date_time DESC LIMIT 1" cursor.execute(base, params) row = cursor.fetchone() if not row: conn.close() return {"workout": None} workout = _hydrate_workout(conn, _row_to_dict(row)) conn.close() return {"workout": workout}