{# Vendored from packages/web/src/governor_web/templates/opportunities/_table.html. Audit changes: - Column-header click → plain with ?sort=...&direction=... so the table sorts via standard GET round-trip (no SSE). - Local-runtime branches kept (audit IS local) — so the Occurrences column doesn't render and the workload chip falls back to "Unclassified" when the kind is unknown. - Row click target: /opportunities/{id} (audit has no /projects/... namespace; everything is single-tenant). - State column: derived from severity bucket (audit has no solution_risk_level / recommendation_state). Same chip grammar (ui-signal-chip + ui-legend-dot). #}
{% if opportunities and opportunities | length > 0 %}
{% set exp_cols = [ ('project', 'Project', 'left'), ('table', 'Object', 'left'), ('type', 'Type', 'left'), ('workload', 'Workload', 'left'), ('cost', 'Query Cost', 'right'), ('savings', 'Savings', 'right'), ] %} {% if not local_runtime_mode %} {% set exp_cols = exp_cols + [('occurrence', 'Occurrences', 'right')] %} {% endif %} {% set exp_cols = exp_cols + [('age', 'Last Detected', 'right')] %} {% for col_key, col_label, col_align in exp_cols %} {% set _next_dir = 'asc' if (signals.sort == col_key and signals.direction == 'desc') else 'desc' %} {% set _qs = pagination.query_string_without_sort_or_page %} {% set _sep = '&' if _qs else '' %} {% set _href = '?' ~ _qs ~ _sep ~ 'sort=' ~ col_key ~ '&direction=' ~ _next_dir %} {# ` {% endfor %} {% set _state_dir = 'desc' if (signals.sort == 'state' and signals.direction == 'asc') else 'asc' %} {% set _qs = pagination.query_string_without_sort_or_page %} {% set _sep = '&' if _qs else '' %} {% for opp in opportunities %} {% if not local_runtime_mode %} {% endif %} {% endfor %}
` instead of wrapping in an `` so the absolute-positioned tooltip doesn't get clipped by the anchor's own bounding box. Same column click-to-sort grammar the cloud uses. #} {% if col_key in ('cost', 'savings') %}
{% if col_key == 'cost' %} Cost from the most recent BigQuery job execution, dry-run estimate, or detection heuristic. {% else %} Estimated per-run savings from solution dry-runs or detection heuristics. {% endif %} {{ col_label }}{% if signals.sort == col_key %} {{ '↓' if signals.direction == 'desc' else '↑' }}{% endif %}
{% else %} {{ col_label }}{% if signals.sort == col_key %} {{ '↓' if signals.direction == 'desc' else '↑' }}{% endif %} {% endif %}
Severity reflects the rule's confidence × cost ceiling. Critical ≥80, High ≥50, Medium ≥20, Low <20. {# Renamed from "State" — audit has no solution lifecycle to track (no Safe/Review/Generating). The column shows the severity bucket pill instead, so call it that. #} Severity{% if signals.sort == 'state' %} {{ '↓' if signals.direction == 'desc' else '↑' }}{% endif %}
{{ 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 {% elif local_runtime_mode %} Unclassified {% else %} Query {% endif %} {% if opp.query_cost_value is not none %} {{ opp.query_cost_value | format_usd }} {% else %} {% endif %} {% if opp.possible_savings_value is not none %} ~{{ opp.possible_savings_value | format_usd }} {% else %} {% 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 "—") }} {# Audit derives State from severity bucket — same chip grammar (ui-signal-chip + ui-legend-dot) the cloud uses for solution risk levels. #} {% if opp.severity_bucket == 'critical' %} Critical · {{ opp.severity_score }} {% elif opp.severity_bucket == 'high' %} High · {{ opp.severity_score }} {% elif opp.severity_bucket == 'medium' %} Medium · {{ opp.severity_score }} {% else %} Low · {{ opp.severity_score }} {% endif %}
{% include "opportunities/_pagination.html" %} {% else %}

No opportunities match your filters

{% endif %}