{% if opportunities and opportunities | length > 0 %}
{# Sortable column headers #} {% set exp_cols = [ ('project', 'Project', 'left'), ('table', 'Table', 'left'), ('type', 'Type', 'left'), ('workload', 'Workload', 'left'), ('cost', 'Query Cost', 'right'), ('savings', 'Savings', 'right'), ('status', 'Status', 'left'), ('occurrence', 'Occurrences', 'right'), ('age', 'Last Detected', 'right'), ] %} {% for col_key, col_label, col_align in exp_cols %} {% endfor %} {% for opp in opportunities %} {% endfor %}
{% if col_key in ('cost', 'savings', 'status') %}
{% if col_key == 'cost' %} Cost from the most recent BigQuery job execution, dry-run estimate, or detection heuristic. {% elif col_key == 'savings' %} Estimated per-run savings from solution dry-runs or detection heuristics. {% else %} Active = detected, open for action. PR Pending = fix submitted. Clearing = fix merged, verifying savings. Resolved = confirmed fixed. {% endif %} {{ col_label }}
{% else %} {{ col_label }} {% endif %}
Safe = low risk, apply directly. Review = check changes first. High risk = may affect downstream queries. Pending = not yet generated. Solution
{{ opp.project_name }} {{ opp.dbt_model_name if opp.dbt_model_name else (opp.affected_table.split('.')[-1] if '.' in opp.affected_table else opp.affected_table) }} {{ opp.opportunity_type | replace('_', ' ') }} {% if opp.query_workload_kind == 'build' %} Build {% elif opp.query_workload_kind == 'consumption' %} Consumption {% else %} Other {% endif %} {% if opp.query_cost_value is not none %} {{ opp.query_cost_value | format_usd }} {% else %} {% endif %} {% if opp.solution_job_status in ('queued', 'in_progress') %} Generating {% elif opp.possible_savings_value is not none %} ~{{ opp.possible_savings_value | format_usd }} {% elif opp.optimized_cost_value is not none %} {{ opp.optimized_cost_value | format_usd }} {% if opp.optimized_delta_direction == 'down' %} {% elif opp.optimized_delta_direction == 'up' %} {% endif %} {% else %} {% endif %} {% if opp.status == 'pr_pending' %} PR Pending {% elif opp.status == 'active' %} Active {% elif opp.status == 'clearing' %} Clearing {% else %} Resolved {% endif %} {{ opp.occurrence_count }} {{ opp.last_detected_at.strftime("%d/%m/%Y") if opp.last_detected_at else (opp.created_at.strftime("%d/%m/%Y") if opp.created_at else "—") }} {% if opp.solution_risk_level == 'low' %} Safe {% elif opp.solution_risk_level == 'medium' %} Review {% elif opp.solution_risk_level == 'high' %} High risk {% elif opp.solution_job_status in ('queued', 'in_progress') %} {{ 'Running' if opp.solution_job_status == 'in_progress' else 'Queued' }} {% else %} Pending {% endif %}
{% include "opportunities/_pagination.html" %} {% else %}

No opportunities match your filters

{% endif %}