{# 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). #}
{% from "components/_sort_header.html" import sort_header %} {% if opportunities and opportunities | length > 0 %} {% set _qs = pagination.query_string_without_sort_or_page %}
{# Audit always renders local_runtime_mode. The 'Savings' and 'Occurrences' columns are cloud-only and never show here. #} {{ sort_header("dataset", "Dataset", signals.sort, signals.direction, base_qs=_qs) }} {{ sort_header("table", "Object", signals.sort, signals.direction, base_qs=_qs) }} {{ sort_header("author", "Author", signals.sort, signals.direction, base_qs=_qs) }} {{ sort_header("type", "Issue", signals.sort, signals.direction, base_qs=_qs) }} {{ sort_header("workload", "Workload", signals.sort, signals.direction, base_qs=_qs) }} {{ sort_header("origin", "Origin", signals.sort, signals.direction, base_qs=_qs, tooltip="Tool that submitted the job (Looker, dbt, Fivetran, Airflow, ad-hoc, ...). Spec 156.") }} {{ sort_header("cost", "Query Cost", signals.sort, signals.direction, align="right", base_qs=_qs, tooltip="Aggregated BigQuery-billed cost across every cached execution of this logical job within the scan window (matches the dashboard's Top Cost Drivers numbers).") }} {{ sort_header("age", "Last Detected", signals.sort, signals.direction, align="right", base_qs=_qs) }} {# Partition / Cluster column removed - partition + cluster recommendations are a data-lineage-level signal, not a per-job one, and don't belong on a job-level listing. #} {{ sort_header("materialization", "Materialization Suggestion", signals.sort, signals.direction, align="center", base_qs=_qs) }} {{ sort_header("suggestions", "SQL Suggestions", signals.sort, signals.direction, align="center", base_qs=_qs) }} {% 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. #} {% endfor %}
{{ opp.affected_dataset }} {{ opp.affected_object }} {% if opp.author_email %} {{ opp.author_email }} {% else %} - {% endif %} {# Issue cell mirrors the Failures table's Reason chip styling (ui-signal-chip + dot) but in amber instead of rose, so detection findings read with the same visual grammar as BigQuery error reasons while the colour still signals "performance issue, not failure". Shows first issue + ``+N`` overflow indicator when the table fires more than one rule; the full list lives in the wrapper's ``title`` tooltip. #} {% set _issue_count = opp.table_issue_count or 0 %} {% set _issue_types = opp.table_issue_types or [] %} {% from "components/_signal_chip.html" import signal_chip %} {% if _issue_count == 0 %} - {% else %}
{{ signal_chip( _issue_types[0] | replace('_', ' ') | upper, color="amber", overflow=("+" ~ (_issue_count - 1)) if _issue_count > 1 else None ) }}
{% endif %}
{% if opp.query_workload_kind == 'build' %} {{ signal_chip("Build", color="brand", title="This logical job materialises data (CTAS, MERGE, INSERT, UPDATE, DELETE, TRUNCATE).") }} {% elif opp.query_workload_kind == 'consumption' %} {{ signal_chip("Consumption", color="teal", title="This logical job reads data (SELECT).") }} {% else %} {{ signal_chip("Unclassified", color="slate", title="Workload couldn't be determined from this job's statement type - typically a CALL / scripting / no-DML statement.") }} {% endif %} {# Spec 156 - Origin column. Shows the classified tool for the representative job. ad_hoc renders as a muted slate chip so it doesn't compete visually with real tool attributions. #} {% set _origin = opp.origin_tool or 'ad_hoc' %} {% if _origin == 'ad_hoc' %} {{ signal_chip("ad-hoc", color="slate", title="No labelled origin tool detected - direct console / API / bq CLI query") }} {% else %} {{ signal_chip(_origin | replace('_', ' '), color="indigo", title="Job submitted by " ~ _origin ~ ". See methodology for the label rules.") }} {% endif %} {% if opp.query_cost_value is not none %} {{ opp.query_cost_value | format_usd }} {% else %} - {% endif %} {{ 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 "-") }} {# Merged Materialization column (post-spec-155). Shows the strategy chip when this row IS a materialization candidate (ephemeral / incremental / table / materialized view) OR the "unused" chip when this row IS an unused destination table. Different chip colours so the two semantics stay visually distinct sharing one column: brand (blue) = strategy recommendation amber = unused (review) Empty cell when neither signal applies. #} {% set _label = opp.materialization_label %} {% if _label == "unused" %} {{ signal_chip(_label, color="amber", title="Built in the scan window but no other query reads from it. Open the row to review.") }} {% elif _label %} {{ signal_chip(_label, color="brand", title="Open the row to see the materialization recommendation.") }} {% endif %} {# Suggestions count - aggregated per table. When zero, render an empty cell rather than a "None" chip - keeps the table chrome clean and visually matches the empty-state convention used in the Issue column. #} {% set _sugg = opp.table_suggestion_count or 0 %} {% if _sugg > 0 %} {{ signal_chip(_sugg ~ " suggested", color="emerald", title=_sugg ~ " SQL-rewrite suggestion(s) fired across this table - open the row to see each diff") }} {% endif %}
{# The opportunities listing groups by ``affected_table`` (one row per table), so the footer noun should reflect that to avoid colliding mentally with the "Flagged Jobs" headline above (which dedupes by destination_table / query_hash). #} {% with pagination_item_noun = "affected tables" %} {% include "components/_pagination.html" %} {% endwith %} {% else %}

No opportunities match your filters

{% endif %}