feat: BLS-Stammdaten, FDDB-Mapping und Item-Tagebuch (#106)
Katalog, lernendes Mapping ohne KI, optionale Items und Import-Policy. Playwright-Smoke und Issue-Audit um Ernährung/Zuordnen/API ergänzt. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
72d101415f
commit
919c77fcf8
39 files changed
+2648
-47
No files matched your search
@@ -223,6 +223,40 @@ def _import_nutrition(
|
||||
|
||||
skipped_groups = sum(n.get("rows_in_group", 0) for n in (agg_notes or []) if n.get("error") == "mehrere_zeilen_pro_schluessel")
|
||||
|
||||
item_rows = []
|
||||
for mapped in mapped_rows:
|
||||
name = mapped.get("food_name")
|
||||
if not name:
|
||||
continue
|
||||
d_item = coerce_date(mapped.get("date"))
|
||||
if d_item is None:
|
||||
continue
|
||||
item_rows.append({
|
||||
"date": d_item.isoformat(),
|
||||
"logged_at": mapped.get("logged_at") or mapped.get("date"),
|
||||
"food_name": str(name).strip(),
|
||||
"quantity_raw": mapped.get("quantity_raw"),
|
||||
"kcal": mapped.get("kcal"),
|
||||
"protein_g": mapped.get("protein_g"),
|
||||
"fat_g": mapped.get("fat_g"),
|
||||
"carbs_g": mapped.get("carbs_g"),
|
||||
})
|
||||
if item_rows:
|
||||
from data_layer.nutrition_items import get_import_policy, replace_csv_items_for_dates
|
||||
|
||||
policy = get_import_policy(cur, profile_id)
|
||||
ingest = replace_csv_items_for_dates(cur, profile_id, item_rows, policy=policy)
|
||||
return {
|
||||
"rows_total": rows_total,
|
||||
"inserted": ingest.get("new_log_days", 0),
|
||||
"updated": max(0, ingest.get("days_written", 0) - ingest.get("new_log_days", 0)),
|
||||
"skipped": skipped_groups,
|
||||
"new_entries": ingest.get("new_log_days", 0),
|
||||
"items_written": ingest.get("items_written", 0),
|
||||
"conflicts": ingest.get("conflicts") or [],
|
||||
"policy": ingest.get("policy"),
|
||||
}
|
||||
|
||||
inserted = 0
|
||||
updated = 0
|
||||
new_entries = 0
|
||||
|
||||
@@ -20,6 +20,8 @@ MODULE_DEFINITIONS: Dict[str, Dict[str, Any]] = {
|
||||
"protein_g": {"type": "float", "required": False, "min": 0, "unit": "g"},
|
||||
"fat_g": {"type": "float", "required": False, "min": 0, "unit": "g"},
|
||||
"carbs_g": {"type": "float", "required": False, "min": 0, "unit": "g"},
|
||||
"food_name": {"type": "string", "required": False, "label_de": "Lebensmittel"},
|
||||
"quantity_raw": {"type": "string", "required": False, "label_de": "Menge"},
|
||||
},
|
||||
"duplicate_key": ["profile_id", "date"],
|
||||
"duplicate_strategy": "update",
|
||||
|
||||
Reference in new issue
Block a user