{# 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 %} {% from "components/_signal_chip.html" import signal_chip %} {% if opportunities and opportunities | length > 0 %} {% set _qs = pagination.query_string_without_sort_or_page %} {% if total_opportunity_rows is defined and pagination.total_items != total_opportunity_rows %}

Showing {{ pagination.total_items }} of {{ total_opportunity_rows }} affected tables

{% endif %}
{# 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("type", "Signal", 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("suggestions", "Suggestions", signals.sort, signals.direction, align="center", base_qs=_qs, tooltip="Materialization and SQL rewrite suggestions for this object.") }} {% 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.display_object or opp.affected_object }} {% if opp.author_label %} {{ opp.author_label }} {% endif %} {% if opp.is_anonymous_result %} anonymous destination {% elif opp.is_consumption_pattern %} query pattern {% 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 [] %} {% set _issue_labels = opp.table_issue_labels or [] %} {% if _issue_count == 0 %} - {% else %}
{{ signal_chip( _issue_labels[0] if _issue_labels else (_issue_types[0] | replace('_', ' ') | title), 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 }} {% if opp.execution_count %} {{ opp.execution_count }} {{ "run" if opp.execution_count == 1 else "runs" }} {% endif %} {% 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 "-") }} {# Combined suggestion column. Materialization and SQL rewrite signals share one compact cell so the table keeps its job-level scanability. #} {% set _label = opp.materialization_label %} {% set _sugg = opp.table_suggestion_count or 0 %} {% if _label or _sugg > 0 %}
{% 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 %} {% if _sugg > 0 %} {{ signal_chip(_sugg ~ " SQL", color="emerald", title=_sugg ~ " SQL-rewrite suggestion(s) fired across this table - open the row to see each diff") }} {% endif %}
{% else %} - {% 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 %}