diff --git a/app.py b/app.py index fbb79f2..4da2de1 100644 --- a/app.py +++ b/app.py @@ -2854,6 +2854,15 @@ def list_products(): unique_items.append(item) seen_names.add(key) + usage_counts = dict( + db.session.query( + func.lower(Item.name), + func.coalesce(func.sum(Item.quantity), 0) + ) + .group_by(func.lower(Item.name)) + .all() + ) + total_items = len(unique_items) total_pages = (total_items + per_page - 1) // per_page start = (page - 1) * per_page @@ -2882,14 +2891,6 @@ def list_products(): if name not in used_suggestion_names ] - usage_counts = dict( - db.session.query( - func.lower(Item.name), - func.coalesce(func.sum(Item.quantity), 0) - ) - .group_by(func.lower(Item.name)) - .all() - ) query_string = urlencode({k: v for k, v in request.args.items() if k != "page"})