feat: Zutaten im Listendialog dem BLS zuordnen
Deploy Development / deploy (push) Successful in 59s
Build Test / pytest-backend (push) Successful in 4s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 23s

Mapping-Status pro Zutat, Suche zuerst Listen und eigene Foods.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
LarsandCursor committed 2026-09-13 14:38:42 +02:00
1 parent b37005be01
commit a5adff6196
10 files changed
+237 -23

No files matched your search

+30
View File
@@ -146,6 +146,36 @@ def link_recipes_to_items(cur, profile_id: str) -> tuple[int, list[str]]:
return linked, list(dates)
def list_known_ingredient_names(cur, profile_id: str, limit: int = 2000) -> list[dict[str, Any]]:
"""Distinct list-ingredient names, with mapping if already learned."""
cur.execute(
"""
SELECT i.source_name_raw, i.source_name_normalized,
MIN(m.food_id::text) AS food_id,
MIN(f.name_de) AS food_name_de,
MIN(f.bls_code) AS bls_code,
BOOL_OR(m.id IS NOT NULL) AS mapped
FROM food_recipe_ingredients i
JOIN food_recipes r ON r.id = i.recipe_id
LEFT JOIN food_name_mappings m
ON m.profile_id = r.profile_id
AND m.source_name_normalized = i.source_name_normalized
LEFT JOIN food_catalog f ON f.id = m.food_id
WHERE r.profile_id = %s
GROUP BY i.source_name_raw, i.source_name_normalized
ORDER BY i.source_name_normalized
LIMIT %s
""",
(profile_id, limit),
)
out = []
for row in cur.fetchall():
rec = dict(row)
rec["mapped"] = bool(rec.get("mapped"))
out.append(rec)
return out
def list_recipes(cur, profile_id: str, with_ingredients: bool = True) -> list[dict[str, Any]]:
cur.execute(
"""