TICKET-007 (backend): meals — from-log, unpack, components, recursive nutrition, cycle detection
This commit is contained in:
@@ -4,7 +4,7 @@ from fastapi import APIRouter, Depends, HTTPException, Query
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from database import get_db
|
||||
from schemas import FoodCreate, FoodRead, FoodUpdate
|
||||
from schemas import FoodCreate, FoodRead, FoodUpdate, MealRead
|
||||
from services.foods import (
|
||||
BarcodeConflictError,
|
||||
create_food,
|
||||
@@ -43,9 +43,11 @@ def _list_foods(
|
||||
include_deleted=include_deleted)
|
||||
|
||||
|
||||
@router.get("/{food_id}", response_model=FoodRead)
|
||||
@router.get("/{food_id}")
|
||||
def _get_food(food_id: int, db: Session = Depends(get_db)):
|
||||
"""Get a single food, including soft-deleted ones (for historical logs)."""
|
||||
"""Get a single food, including soft-deleted ones (for historical logs).
|
||||
Returns MealRead (with components + computed nutrition) for meals,
|
||||
plain FoodRead for non-meals."""
|
||||
food = get_food(db, food_id)
|
||||
if food is None:
|
||||
raise HTTPException(status_code=404, detail="Food not found")
|
||||
|
||||
Reference in New Issue
Block a user