fix: Offene Lebensmittel nach Listen-Import wieder anzeigen
Deploy Development / deploy (push) Successful in 1m1s
Build Test / pytest-backend (push) Failing after 2s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 27s

Unmapped ohne Kreuzjoin, Listen-GET kurz, Rebuild im Hintergrund.
Tandoor-Zugang (URL/Token) in den Einstellungen mit ausliefern.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
LarsandCursor committed 2026-09-13 10:36:08 +02:00
1 parent fa542e0fb9
commit d6838abda7
23 files changed
+786 -114

No files matched your search

+23
View File
@@ -1,10 +1,14 @@
"""Nutrition diary items, three macro sums, import policy, attribute resolve."""
from __future__ import annotations
import logging
import threading
import uuid
from datetime import date, datetime
from typing import Any
logger = logging.getLogger(__name__)
from data_layer.food_mapping import (
get_food_mapping_with_cursor,
normalize_food_name,
@@ -222,6 +226,25 @@ def _accumulate_food_qty(cur, acc: dict[int, list[float]], food_id: str, quantit
acc.setdefault(row["attribute_id"], []).append(float(row["value_num"]) * factor)
def schedule_daily_nutrient_rebuild(profile_id: str, dates: list[str], context: str) -> None:
days = [str(d) for d in (dates or []) if d]
if not days:
return
def _run() -> None:
try:
from db import get_cursor, get_db
with get_db() as conn:
cur = get_cursor(conn)
for day in days:
rebuild_daily_nutrients(cur, profile_id, day)
except Exception:
logger.exception("Nährwert-Rebuild nach %s fehlgeschlagen", context)
threading.Thread(target=_run, daemon=True, name="nutrition-rebuild").start()
def rebuild_daily_nutrients(cur, profile_id: str, day: date | str) -> None:
cur.execute(
"DELETE FROM nutrition_daily_nutrients WHERE profile_id = %s AND date = %s",