feat: Zuordnen ohne Freeze und zuerst die letzten Wochen
Katalogsuche und Bestätigen blockieren die UI nicht mehr; offene Namen starten bei den aktuellen Tagebucheinträgen, alter Ballast bleibt unter Alle. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
c1873a47b1
commit
132a364a3a
17 files changed
+745
-163
No files matched your search
@@ -1,5 +1,13 @@
|
||||
from datetime import date
|
||||
|
||||
from csv_parser.executor import guess_nutrition_item_fields
|
||||
from data_layer.food_mapping import merge_unmapped_rows, normalize_food_name, parse_quantity, parse_quantity_g
|
||||
from data_layer.food_mapping import (
|
||||
filter_unmapped_since,
|
||||
merge_unmapped_rows,
|
||||
normalize_food_name,
|
||||
parse_quantity,
|
||||
parse_quantity_g,
|
||||
)
|
||||
from data_layer.nutrition_items import macros_differ
|
||||
|
||||
|
||||
@@ -42,6 +50,18 @@ def test_guess_fddb_bezeichnung_without_template_mapping():
|
||||
assert qty == "50 g"
|
||||
|
||||
|
||||
def test_recent_window_drops_old_and_dateless_foods():
|
||||
today = date(2026, 9, 12)
|
||||
rows = [
|
||||
{"source_name_raw": "Haferflocken", "last_date": "2026-09-10", "count": 2},
|
||||
{"source_name_raw": "Weißbrot", "last_date": "2026-01-02", "count": 40},
|
||||
{"source_name_raw": "Altes Rezept-Salz", "last_date": None, "count": 1},
|
||||
]
|
||||
recent = filter_unmapped_since(rows, 28, today=today)
|
||||
assert [r["source_name_raw"] for r in recent] == ["Haferflocken"]
|
||||
assert len(filter_unmapped_since(rows, 0, today=today)) == 3
|
||||
|
||||
|
||||
def test_macros_differ_rounds():
|
||||
assert not macros_differ({"kcal": 1.04, "protein_g": 0, "fat_g": 0, "carbs_g": 0}, {"kcal": 1.0, "protein_g": 0, "fat_g": 0, "carbs_g": 0})
|
||||
assert macros_differ({"kcal": 10, "protein_g": 0, "fat_g": 0, "carbs_g": 0}, {"kcal": 11, "protein_g": 0, "fat_g": 0, "carbs_g": 0})
|
||||
Reference in new issue
Block a user