feat: Rezepte beim Zuordnen anlegen und offene Zutaten listen
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:
1 parent
132a364a3a
commit
a7e5511039
26 files changed
+1234
-147
No files matched your search
@@ -264,21 +264,5 @@ def admin_create_attribute(body: AttributeCreate, session: dict = Depends(requir
|
||||
|
||||
|
||||
def _write_manual_macros(cur, food_id: str, macros: dict | None) -> None:
|
||||
if not macros:
|
||||
return
|
||||
mapping = {"kcal": "ENERCC", "protein_g": "PROT625", "fat_g": "FAT", "carbs_g": "CHO"}
|
||||
for field, key in mapping.items():
|
||||
if field not in macros or macros[field] is None:
|
||||
continue
|
||||
cur.execute("SELECT id FROM food_attributes WHERE attr_key = %s", (key,))
|
||||
row = cur.fetchone()
|
||||
if not row:
|
||||
continue
|
||||
cur.execute(
|
||||
"""
|
||||
INSERT INTO food_attribute_values (food_id, attribute_id, value_num, is_trace)
|
||||
VALUES (%s, %s, %s, false)
|
||||
ON CONFLICT (food_id, attribute_id) DO UPDATE SET value_num = EXCLUDED.value_num, updated_at = NOW()
|
||||
""",
|
||||
(food_id, row["id"], float(macros[field])),
|
||||
)
|
||||
from data_layer.food_attributes import macros_and_attributes_to_values, write_numeric_attributes
|
||||
write_numeric_attributes(cur, food_id, macros_and_attributes_to_values(macros, None))
|
||||
Reference in new issue
Block a user