get meals bugs
This commit is contained in:
parent
a137199400
commit
f76eed3cde
2 changed files with 6 additions and 6 deletions
10
main.py
10
main.py
|
|
@ -109,16 +109,16 @@ async def create_recipe(item: recipes.Recipe, conn: sqlite3.Connection = Depends
|
|||
return item
|
||||
|
||||
@app.get("/meals/")
|
||||
async def get_meals(start: datetime.datetime, end: datetime.datetime, conn: sqlite3.Connection = Depends(get_db)) -> List[meals.Meal]:
|
||||
async def get_meals(date_from: Annotated[datetime.datetime, Query(alias='from')], to: datetime.datetime, conn: sqlite3.Connection = Depends(get_db)) -> List[meals.Meal]:
|
||||
result = []
|
||||
async for meal in meals.find_meals_by_date_range(conn, start, end):
|
||||
meal.recipe = await load_full_recipe(conn, meal.recipe_id)
|
||||
for meal in await meals.find_meals_by_date_range(conn, date_from, to):
|
||||
meals.load_recipes(conn, meal)
|
||||
result.append(meal)
|
||||
|
||||
return result
|
||||
|
||||
@app.get("/meals/{meal_id}")
|
||||
async def get_meal(meal_id: int, request: Request, conn: sqlite3.Connection = Depends(get_db)) -> meals.Meal:
|
||||
async def get_meal(meal_id: int, conn: sqlite3.Connection = Depends(get_db)) -> meals.Meal:
|
||||
meal = await meals.find_meal_by_id(conn, meal_id)
|
||||
if not meal:
|
||||
return JSONResponse(status_code=404, content={'message': 'Meal not found'})
|
||||
|
|
@ -126,7 +126,7 @@ async def get_meal(meal_id: int, request: Request, conn: sqlite3.Connection = De
|
|||
await meals.load_participants(conn, meal)
|
||||
await meals.load_recipes(conn, meal)
|
||||
await meals.load_extra_ingredients(conn, meal)
|
||||
|
||||
|
||||
return meal
|
||||
|
||||
@app.post("/meals/")
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ class Meal(BaseModel):
|
|||
chef: List[Person] = []
|
||||
cleanup: List[Person] = []
|
||||
consumers: List[Person] = []
|
||||
recipes: List[Person] = []
|
||||
recipes: List[Recipe] = []
|
||||
extra_ingredients: List[Ingredient] = []
|
||||
|
||||
async def create(conn):
|
||||
|
|
|
|||
Loading…
Reference in a new issue