Skip to content

Commit

Permalink
updating get training_week request model
Browse files Browse the repository at this point in the history
  • Loading branch information
voynow committed Nov 9, 2024
1 parent 027bb59 commit 79d529d
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions api/src/main.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
from fastapi import Depends, FastAPI, HTTPException
from src.auth_manager import get_current_user
from src.supabase_client import TrainingWeek, get_training_week
from src.types.user import UserRow

app = FastAPI()


@app.get("/training_week/{athlete_id}", response_model=TrainingWeek)
async def training_week_endpoint(athlete_id: int, _: dict = Depends(get_current_user)):
@app.get("/training_week/", response_model=TrainingWeek)
async def training_week_endpoint(user: UserRow = Depends(get_current_user)):
"""
Retrieve the most recent training_week row by athlete_id
curl -X GET "http://localhost:8000/training_week/{athlete_id}" \
Expand All @@ -16,6 +17,6 @@ async def training_week_endpoint(athlete_id: int, _: dict = Depends(get_current_
:return: The most recent training_week row for the athlete
"""
try:
return get_training_week(athlete_id)
return get_training_week(user.athlete_id)
except ValueError as e:
raise HTTPException(status_code=404, detail=str(e))

0 comments on commit 79d529d

Please sign in to comment.