{# Spec 125: one row per dbt model (local-mode grouping). Expects: model_groups: list[dict] — ModelGroup DTOs from OpportunityExplorerService.query_model_groups pagination: PaginationContext #}
{% if model_groups and model_groups | length > 0 %}
{% set mg_cols = [ ('project', 'Project', 'left'), ('table', 'Object', 'left'), ('type', 'Type', 'left'), ('workload', 'Workload', 'left'), ('cost', 'Query Cost', 'right'), ('savings', 'Savings', 'right'), ('age', 'Last Detected', 'right'), ] %} {% for col_key, col_label, col_align in mg_cols %} {% endfor %} {% for g in model_groups %} {% set model_url = '/projects/' ~ g.config_id ~ '/models/' ~ (g.dbt_model_name | urlencode) %} {% endfor %}
{{ col_label }} State
{{ g.project_name }} {{ g.dbt_model_name }} {% if g.opportunity_count > 1 %} {{ g.opportunity_count }} issues {% endif %} {% if g.opportunity_count == 1 %} {{ g.opportunity_types[0] | replace('_', ' ') }} {% else %} {# Show first 2 types + "+N more" if there are further ones #} {{ g.opportunity_types[0] | replace('_', ' ') }}{% if g.opportunity_types | length >= 2 %}, {{ g.opportunity_types[1] | replace('_', ' ') }}{% endif %}{% if g.opportunity_types | length > 2 %} +{{ g.opportunity_types | length - 2 }} more{% endif %} {% endif %} {% if g.workload_kind == 'build' %} Build {% elif g.workload_kind == 'consumption' %} Consumption {% elif g.workload_kind == 'mixed' %} Mixed {% else %} Unclassified {% endif %} {% if g.total_query_cost_value is not none %} {{ g.total_query_cost_value | format_usd }} {% else %} {% endif %} {% if g.total_savings_value is not none and g.total_savings_value > 0 %} ~{{ g.total_savings_value | format_usd }} {% else %} {% endif %} {{ g.last_detected_at.strftime("%d/%m/%Y") if g.last_detected_at else "—" }} {% if g.worst_state == 'high_risk' %} High risk {% elif g.worst_state == 'failed' %} Failed {% elif g.worst_state == 'requires_review' %} Review {% elif g.worst_state == 'generating' %} Generating {% elif g.worst_state == 'upstream_fix' %} Upstream fix {% elif g.worst_state == 'safe' %} Safe {% elif g.worst_state == 'resolved' %} Resolved {% elif g.worst_state == 'skipped' %} Skipped {% else %} Awaiting {% endif %}
{% include "opportunities/_pagination.html" %} {% else %}

No opportunities match your filters

{% endif %}