{# 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 %}
{# 'Savings' column dropped in v0.0.16 — audit doesn't run dry-runs and refuses to display the existing rules' hard- coded percentage savings. See _DEFAULT_SORT comment in routes/opportunities.py. #} {% set exp_cols = [ ('dataset', 'Dataset', 'left'), ('table', 'Object', 'left'), ('author', 'Author', 'left'), ('type', 'Issue', 'left'), ('workload', 'Workload', 'left'), ('cost', 'Query Cost', '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 %} {% for opp in opportunities %} {# Each row represents ONE destination_table, aggregated across every Opportunity that fired on it. Click goes to the representative opportunity's detail page (/opportunities/{id}) — same recommendation layout users are familiar with. The detail page itself links onward to the cohort view (/jobs/{table}) for the full per-rule history if they want to dive deeper. #} {# Savings cell removed in v0.0.16. #} {% 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 %}
Number of SQL-rewrite improvements that apply to the same query as this issue. Click into the row to see each diff. Suggestions
{{ opp.affected_dataset }} {{ opp.affected_object }} {% if opp.author_email %} {{ opp.author_email }} {% else %} {% endif %} {# Issue cell renders aggregated: - 0 issue rules fired → "—" - 1-3 issue rules → comma-separated list of all names - 4+ → first three + " + N more" with full list in the title attribute so users can see them on hover. #} {% set _issue_count = opp.table_issue_count or 0 %} {% set _issue_types = opp.table_issue_types or [] %} {% if _issue_count == 0 %} {% elif _issue_count <= 3 %} {{ _issue_types | map('replace', '_', ' ') | join(', ') }} {% else %} {{ _issue_types[:3] | map('replace', '_', ' ') | join(', ') }} + {{ _issue_count - 3 }} more {% endif %} {% 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 %} {{ 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 "—") }} {# Suggestions count — aggregated per table. ``table_suggestion_count`` is the number of distinct suggestion rules that fired across this table's opportunities. Click a row to see the per-rule diffs on the cohort page. #} {% set _sugg = opp.table_suggestion_count or 0 %} {% set _sugg_diff = _sugg %} {% if _sugg == 0 %} None {% elif _sugg_diff > 0 %} {{ _sugg }} suggested · {{ _sugg_diff }} with diff {% else %} {{ _sugg }} suggested {% endif %}
{% include "opportunities/_pagination.html" %} {% else %}

No opportunities match your filters

{% endif %}