{# Cohort view for /jobs/{destination_table}. Renders every cached execution of one BigQuery destination_table as a single page: cost-trend chart + Available improvements (latest version's suggestions only) + chronological Query versions list. See specs/146-audit-job-history-trend/. #} {% extends "layout.html" %} {% block content %}
Dashboard Jobs {{ view.destination_table }}
{# Consolidated header: title + a thin inline stat row so the page starts with content (chart + versions) above the fold rather than four large stat cards repeating what the breadcrumb already says. Total Cost lives in the chart's panel; we keep the executions / versions counts as plain text in the subtitle. #}

{{ view.destination_table }}

{{ view.total_executions }} execution{% if view.total_executions != 1 %}s{% endif %} · {{ view.versions | length }} query version{% if view.versions | length != 1 %}s{% endif %}{% if view.versions | length > 1 %} ({{ view.versions | length - 1 }} change{% if view.versions | length != 2 %}s{% endif %} in window){% endif %} · {{ view.days_with_executions }} active day{% if view.days_with_executions != 1 %}s{% endif %}

Total cost

{{ view.total_cost_usd | format_usd }}

{# Cost-trend chart - line + version-change scatter overlay. #} {% set chart_points_payload = view.chart_points_payload() %} {% include "jobs/_cost_chart.html" %} {# Available improvements - collapsed by default. The page's primary surfaces are the cost-trend chart + Query versions; the suggestions belong to the *current* version and are reachable from /opportunities/{id} too, so we don't need to default-render full diff cards on this page. Expand on demand. #}

Available improvements

{% if view.latest_suggestions %} {{ view.latest_suggestions | length }} for current version {% else %} none for current version {% endif %}
{% if view.latest_suggestions %}

SQL-rewrite suggestions for the current query version (v{{ view.versions[-1].version_index }}). Earlier versions' suggestions don't render - see Query versions below for what was resolved.

{% for imp in view.latest_suggestions %}
{{ imp.display_name }} {% if imp.template_id %} deterministic rewrite {% endif %}
{% if imp.explanation %}

{{ imp.explanation }}

{% endif %} {% if imp.diff_lines or imp.before_content %}
{% if imp.diff_lines %} {% set diff_lines = imp.diff_lines %} {% set file_path = imp.template_id %} {% include "components/code_diff.html" %} {% else %}

No diff available - template did not produce a change.

{% endif %}
{% endif %} {% if imp.rollback %}
Rollback instructions

{{ imp.rollback }}

{% endif %}
{% endfor %}
{% else %}

No suggestions for the current query version. {% if view.versions | length > 1 %} Earlier versions may have had findings - see Query versions below for what was resolved. {% endif %}

{% endif %}
{# Query versions - chronological history of distinct query bodies. Each version is collapsed by default; the latest opens automatically because that's the one users came here to read. #} {% from "components/_section_title.html" import section_title %}
{{ section_title( "Query versions", description="Chronological history of distinct query bodies for this destination. Each version's card is collapsed; the latest opens automatically because that's the one users came here to read.", aside=((view.versions | length) ~ " in window · latest is open · click to expand others") ) }}
{% for version in view.versions %} {% set is_latest = loop.last %} {% include "jobs/_version_card.html" %} {% endfor %}
{# Generic tab toggler - picks up any descendant with [data-tab] / [data-tab-pane] inside an ancestor that has [data-active-tab]. Works for both Available improvements (.audit-imp-card) and the version cards (.audit-version-card) without coupling to the class name. #} {% endblock %}