No double loading products
This commit is contained in:
parent
b794b6d78a
commit
6ba6406427
1 changed files with 0 additions and 4 deletions
4
main.py
4
main.py
|
|
@ -59,7 +59,6 @@ async def load_full_recipe(conn: sqlite3.Connection, id: int) -> recipes.Recipe:
|
|||
|
||||
r.ingredients = []
|
||||
async for ingredient in ingredients.find_ingredients_by_recipe_id(conn, id):
|
||||
ingredient.product = await products.find_product_by_id(conn, ingredient.product_id)
|
||||
r.ingredients.append(ingredient)
|
||||
|
||||
return r
|
||||
|
|
@ -77,7 +76,6 @@ async def get_recipes(q: str | None = None, conn: sqlite3.Connection = Depends(g
|
|||
for recipe in result:
|
||||
recipe.ingredients = []
|
||||
async for ingredient in ingredients.find_ingredients_by_recipe_id(conn, recipe.id):
|
||||
ingredient.product = await products.find_product_by_id(conn, ingredient.product_id)
|
||||
recipe.ingredients.append(ingredient)
|
||||
|
||||
return result
|
||||
|
|
@ -132,7 +130,6 @@ async def get_meal(meal_id: int, conn: sqlite3.Connection = Depends(get_db)) ->
|
|||
|
||||
@app.post("/meals/")
|
||||
async def create_meal(meal: meals.Meal, conn: sqlite3.Connection = Depends(get_db)) -> meals.Meal:
|
||||
"""
|
||||
if not meal.chef:
|
||||
return JSONResponse(status_code=400, content={'message': 'Meal must have at least one chef'})
|
||||
|
||||
|
|
@ -141,7 +138,6 @@ async def create_meal(meal: meals.Meal, conn: sqlite3.Connection = Depends(get_d
|
|||
|
||||
if not meal.consumers:
|
||||
return JSONResponse(status_code=400, content={'message': 'Meal must have at least one consumer'})
|
||||
"""
|
||||
|
||||
if len(meal.recipes) == 0 and len(meal.extra_ingredients) == 0:
|
||||
return JSONResponse(status_code=400, content={'message': 'Meal must have at least one recipe or ingredient'})
|
||||
|
|
|
|||
Loading…
Reference in a new issue