log_workout_session_to_dynamodb
Logs completed workout sessions to DynamoDB by storing session metadata and every exercise set, including weight, reps, RPE, and form ratings for tracking.
Instructions
Log a completed workout session to DynamoDB
Records the actual workout performed including session metadata and all exercise sets.
This creates:
- WorkoutLog (session metadata: start/end time, duration, energy level, etc.)
- ExerciseSetLog (one per set performed with weight, reps, RPE, form rating, etc.)
The workout_log_json should contain:
{
"plan_id": "plan_abc",
"week_number": 1,
"day_number": 1,
"workout_date": "2026-01-06",
"started_at": "2026-01-06T14:30:00Z",
"completed_at": "2026-01-06T15:45:00Z",
"duration_min": 75,
"perceived_difficulty": 8,
"energy_level": 7,
"sleep_quality": 8,
"pre_workout_nutrition": "protein shake + banana",
"bodyweight_lbs": 185,
"status": "completed",
"exercises": [
{
"exercise_id": "bench_press_barbell",
"exercise_name": "Barbell Bench Press",
"sets": [
{
"set_number": 1,
"set_type": "working",
"weight_lbs": 225,
"reps_completed": 5,
"reps_target": 5,
"rpe": 8,
"rir": 2,
"tempo_actual": "2-0-1-0",
"rest_seconds_actual": 180,
"form_rating": 9,
"notes": "Felt strong",
"failed": false,
"spotted": false
}
]
}
]
}
Args:
workout_log_json: JSON string of workout log data
user_id: User ID who performed the workout
log_id: Optional log ID (auto-generated UUID if not provided)
table_name: DynamoDB table name (default: WorkoutPlans)
region: AWS region (default: us-west-2)
Returns:
Dictionary with success status and statistics about logged entities
Example:
result = log_workout_session_to_dynamodb(
workout_log_json='{"plan_id": "plan_abc", "week_number": 1, ...}',
user_id="user_123"
)
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| log_id | No | ||
| region | No | us-west-2 | |
| user_id | Yes | ||
| table_name | No | WorkoutPlans | |
| workout_log_json | Yes |