feat: Rezepte beim Zuordnen anlegen und offene Zutaten listen
Deploy Development / deploy (push) Successful in 1m1s
Build Test / pytest-backend (push) Successful in 8s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 29s

Lebensmittel oder Rezept wählbar; gemappte Zutaten werden übernommen, offene erscheinen in der Liste. Dazu Fettgehalt-Suche, EPA-Stoffe, Rezept-CRUD und Wechsel bestehender Zuordnungen.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
LarsandCursor committed 2026-09-12 16:59:24 +02:00
1 parent 132a364a3a
commit a7e5511039
26 files changed
+1234 -147

No files matched your search

+17 -2
View File
@@ -34,6 +34,8 @@ class UserFoodCreate(BaseModel):
name_de: str
name_en: Optional[str] = None
macros_per_100g: Optional[dict] = None
attributes: Optional[dict] = None
serving_g: Optional[float] = None
class MappingUpsert(BaseModel):
@@ -89,6 +91,17 @@ def search_foods(
return suggest_catalog_foods_ranked(cur, q, pid, limit=min(max(limit, 1), 50))
@router.get("/attributes")
def list_food_attributes(
q: str = "",
limit: int = 40,
session: dict = Depends(require_auth),
):
from data_layer.food_attributes import list_numeric_attributes
with get_db() as conn:
return list_numeric_attributes(get_cursor(conn), q, limit=limit)
@router.post("/foods/suggest-batch")
def suggest_foods_batch(
body: SuggestBatchBody,
@@ -107,13 +120,15 @@ def create_user_food(
x_profile_id: Optional[str] = Header(default=None),
session: dict = Depends(require_auth),
):
from routers.admin_bls import _write_manual_macros
from data_layer.food_attributes import macros_and_attributes_to_values, write_numeric_attributes
import uuid
pid = _pid(session, x_profile_id)
name = (body.name_de or "").strip()
if not name:
raise HTTPException(400, "Name fehlt")
serving = body.serving_g if body.serving_g and body.serving_g > 0 else None
values = macros_and_attributes_to_values(body.macros_per_100g, body.attributes, serving)
with get_db() as conn:
cur = get_cursor(conn)
cur.execute(
@@ -126,7 +141,7 @@ def create_user_food(
(name, body.name_en, pid, f"man-user-{normalize_food_name(name)[:32]}-{uuid.uuid4().hex[:8]}"),
)
food = r2d(cur.fetchone())
_write_manual_macros(cur, food["id"], body.macros_per_100g)
write_numeric_attributes(cur, food["id"], values)
invalidate_suggest_index(pid)
return food