Skip to content

Commit

Permalink
Lambda trigger_test_key hotfix
Browse files Browse the repository at this point in the history
  • Loading branch information
voynow committed Sep 14, 2024
1 parent a330c40 commit 5e81f0c
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 36 deletions.
2 changes: 1 addition & 1 deletion src/lambda_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def lambda_handler(event, context):
return {"success": True}

elif event.get("trigger_test_key") == os.environ["TRIGGER_TEST_KEY"]:
daily_executor(os.environ["JAMIES_ATHLETE_ID"])
return daily_executor(get_user(os.environ["JAMIES_ATHLETE_ID"]))

# Catch any error routing or funny business
else:
Expand Down
66 changes: 31 additions & 35 deletions test.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -173,56 +173,52 @@
"# upsert_training_week(os.environ[\"DANNYS_ATHLETE_ID\"], response)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Trigger Lambda E2E"
]
},
{
"cell_type": "code",
"execution_count": 23,
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"firstname: Jamie\n",
"lastname: Voynow\n",
"email: voynow99@gmail.com\n",
"preferences: Training for a marathon, prefer workouts on wed and long runs on sat\n",
"profile: https://dgalywyr863hv.cloudfront.net/pictures/athletes/98390356/23289449/16/large.jpg\n",
"is_active: True\n"
]
}
],
"outputs": [],
"source": [
"from src.auth_manager import get_strava_client\n",
"from src.supabase_client import get_user\n",
"import requests\n",
"import os\n",
"\n",
"user = get_user(98390356)\n",
"athlete = get_strava_client(98390356).get_athlete()\n",
"url = \"https://lwg77yq7dd.execute-api.us-east-1.amazonaws.com/prod/signup\"\n",
"\n",
"print(\"firstname:\", athlete.firstname)\n",
"print(\"lastname:\", athlete.lastname)\n",
"print(\"email:\", user.email)\n",
"print(\"preferences:\", user.preferences)\n",
"print(\"profile:\", athlete.profile)\n",
"print(\"is_active:\", user.is_active)\n",
"\n"
"response = requests.post(url, json={\n",
" \"trigger_test_key\": os.environ[\"TRIGGER_TEST_KEY\"]\n",
"})"
]
},
{
"cell_type": "code",
"execution_count": 16,
"execution_count": 5,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Jamie\n",
"Voynow\n",
"https://dgalywyr863hv.cloudfront.net/pictures/athletes/98390356/23289449/16/large.jpg\n"
]
"data": {
"text/plain": [
"{'errorMessage': \"'str' object has no attribute 'athlete_id'\",\n",
" 'errorType': 'AttributeError',\n",
" 'requestId': '8efbb5cc-cc5e-4a2d-964d-077e27238abf',\n",
" 'stackTrace': [' File \"/var/task/src/lambda_function.py\", line 160, in lambda_handler\\n daily_executor(os.environ[\"JAMIES_ATHLETE_ID\"])\\n',\n",
" ' File \"/var/task/src/lambda_function.py\", line 109, in daily_executor\\n logging.error(f\"Error processing user {user.athlete_id}: {e}\")\\n']}"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": []
"source": [
"response.json()"
]
},
{
"cell_type": "code",
Expand Down

0 comments on commit 5e81f0c

Please sign in to comment.