{% extends "data_hub/base_data_hub.html" %} {% block data_hub_content %}

Flag Queue {% set total = (flag_count or 0) + (pending_products|length if pending_products else 0) %} {% if total > 0 %} {{ total }} {% endif %}

By String By Recipe Products {% if pending_products and pending_products|length > 0 %} {{ pending_products|length }} {% endif %}
{# ── PRODUCTS PENDING REVIEW ── #} {% if view == 'products' %} {% if not pending_products or pending_products|length == 0 %}
No products pending review.
{% else %}

These products were auto-created by the USDA CSV fallback during import. Review each one — approve if it's a legitimate branded product, merge into ingredients if it belongs there, or delete if it's a duplicate or error.

{% for p in pending_products %}
{{ p.name }}
{{ p.category or '—' }}
{% if p.usda_match_score %}
USDA score: {{ (p.usda_match_score * 100)|int }}%
{% endif %} {% if p.review_reason %}
{% for reason in p.review_reason.split(', ') %} {{ reason }} {% endfor %}
{% endif %}
{# Approve #}
{# Merge into ingredient #}
{# Delete #}
{% endfor %} {% endif %} {# ── GROUPED INGREDIENT FLAGS ── #} {% elif view == 'grouped' %} {% if flag_count == 0 %}
No flagged recipes. Import some recipes to populate this queue.
{% else %}

{{ groups|length }} unique unmatched strings across {{ flag_count }} flagged recipe(s). Resolve each string once — the alias applies to all affected recipes.

{% for group in groups %}
{{ group.string }}
normalized: {{ group.normalized }}
{% for r in group.recipes %} {{ r.title }} {% endfor %}
{{ group.count }} occurrence(s) across {{ group.recipes|length }} recipe(s)
Top suggestions:
{% for s in group.suggestions %}
{% else %} No suggestions. {% endfor %}
{% endfor %} {% endif %} {# ── BY RECIPE VIEW ── #} {% else %} {% if flag_count == 0 %}
No flagged recipes.
{% else %} {% for item in recipes %}
{{ item.recipe.title }}
Unmatched ({{ item.count }}):
{% for u in item.unmatched %} {{ u }} {% endfor %}
{% endfor %} {% endif %} {% endif %} {# Create New Ingredient Modal #} {% endblock %}