fix: FDDB-Zeilen im CSV-Import speichern und in Ernährung zeigen
Bezeichnung/Menge auch ohne Vorlagen-Mapping, Zuordnen-Hinweis, Tagesliste mit Lebensmitteln. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
a07a668de2
commit
4b1be3019d
7 files changed
+141
-5
No files matched your search
@@ -712,6 +712,8 @@ async def csv_import_execute(
|
||||
"updated": result["rows_updated"],
|
||||
"skipped": result["rows_skipped"],
|
||||
"errors": result["rows_errors"],
|
||||
"items_written": result.get("items_written", 0),
|
||||
"unmapped_names": result.get("unmapped_names", 0),
|
||||
},
|
||||
"error_details": result["error_details"],
|
||||
}
|
||||
@@ -227,7 +227,23 @@ def list_nutrition(limit: int=365, x_profile_id: Optional[str]=Header(default=No
|
||||
""",
|
||||
(pid, limit),
|
||||
)
|
||||
return [r2d(r) for r in cur.fetchall()]
|
||||
rows = [r2d(r) for r in cur.fetchall()]
|
||||
dates = [r["date"] for r in rows if r.get("date") is not None]
|
||||
counts = {}
|
||||
if dates:
|
||||
cur.execute(
|
||||
"""
|
||||
SELECT date, COUNT(*) AS item_count
|
||||
FROM nutrition_items
|
||||
WHERE profile_id = %s AND date = ANY(%s)
|
||||
GROUP BY date
|
||||
""",
|
||||
(pid, dates),
|
||||
)
|
||||
counts = {str(r["date"]): int(r["item_count"] or 0) for r in cur.fetchall()}
|
||||
for r in rows:
|
||||
r["item_count"] = counts.get(str(r.get("date")), 0)
|
||||
return rows
|
||||
|
||||
|
||||
@router.get("/by-date/{date}")
|
||||
|
||||
Reference in new issue
Block a user