funckja niekupione - poprawki w szablonie i backendzie

This commit is contained in:
Mateusz Gruszczyński
2025-07-15 23:27:54 +02:00
parent 4ef183e2a9
commit 9dcd144b34
3 changed files with 17 additions and 1 deletions

12
app.py
View File

@@ -723,6 +723,7 @@ def all_products():
top_products_query.order_by(
SuggestedProduct.usage_count.desc(), SuggestedProduct.name.asc()
)
.distinct(SuggestedProduct.name)
.limit(20)
.all()
)
@@ -739,7 +740,16 @@ def all_products():
all_names = top_names + [s.name for s in rest_products]
return {"allproducts": all_names}
seen = set()
unique_names = []
for name in all_names:
name_lower = name.strip().lower()
if name_lower not in seen:
unique_names.append(name)
seen.add(name_lower)
return {"allproducts": unique_names}
""" @app.route('/upload_receipt/<int:list_id>', methods=['POST'])