feat: Stoff-Bezeichnungen editieren und BLS-Glossar fuellen
Kryptische Schluessel bleiben Identitaet; Namen/Einheit sind aenderbar. Nur ENERCC/PROT625/FAT/CHO schreiben die Makro-Haupttabelle. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
e452d9a8fe
commit
94ddf84262
13 files changed
+586
-29
No files matched your search
@@ -16,6 +16,9 @@ def should_persist_value(val: dict[str, Any]) -> bool:
|
||||
|
||||
|
||||
def upsert_attributes(cur, attributes: list[dict[str, Any]]) -> dict[str, int]:
|
||||
from bls.attribute_labels import enrich_attributes_in_memory
|
||||
|
||||
attributes = enrich_attributes_in_memory(list(attributes))
|
||||
inserted = updated = 0
|
||||
for a in attributes:
|
||||
cur.execute(
|
||||
@@ -47,7 +50,15 @@ def upsert_attributes(cur, attributes: list[dict[str, Any]]) -> dict[str, int]:
|
||||
return {"inserted": inserted, "updated": updated, "total": len(attributes)}
|
||||
|
||||
|
||||
def upsert_foods(cur, foods: list[dict[str, Any]], bls_version: str = "4.0") -> dict[str, int]:
|
||||
def upsert_foods(
|
||||
cur,
|
||||
foods: list[dict[str, Any]],
|
||||
bls_version: str = "4.0",
|
||||
attribute_headers: list[dict[str, Any]] | None = None,
|
||||
) -> dict[str, int]:
|
||||
if attribute_headers:
|
||||
from bls.attribute_labels import enrich_labels_from_food_headers
|
||||
enrich_labels_from_food_headers(cur, attribute_headers)
|
||||
cur.execute("SELECT attr_key, id FROM food_attributes")
|
||||
attr_ids = {r["attr_key"]: r["id"] for r in cur.fetchall()}
|
||||
codes = [f["bls_code"] for f in foods if f.get("bls_code")]
|
||||
|
||||
Reference in new issue
Block a user