fix w /all_products

This commit is contained in:
Mateusz Gruszczyński
2025-08-17 18:01:00 +02:00
parent bfcc224a0f
commit 8d0106c56d

13
app.py
View File

@@ -2050,22 +2050,21 @@ def all_products():
.filter(~func.lower(func.trim(SuggestedProduct.name)).in_(used_names))
.all()
)
suggested_fallbacks = [
{"name": row.name.strip(), "count": 0} for row in extra_suggestions
]
if sort == "alphabetical":
products += suggested_fallbacks
products.sort(key=lambda x: x["name"].lower())
else:
products += suggested_fallbacks
if not products:
products = suggested_fallbacks
if sort == "alphabetical":
products.sort(key=lambda x: x["name"].lower())
return jsonify(
{"products": products, "total_count": total_count + len(suggested_fallbacks)}
{"products": products, "total_count": (total_count if products else len(products))}
)
@app.route("/upload_receipt/<int:list_id>", methods=["POST"])
@login_required
def upload_receipt(list_id):