{% extends "layout.html" %} {% block content %}
Pull Requests PR #{{ pr.pr_number }}
{# Header #}

Pull Request

#{{ pr.pr_number }}

{% if pr.status == 'open' %} Open {% elif pr.status == 'merged' %} Merged {% else %} Closed {% endif %} {% if verified_data %} {% if verified_data.status == 'confirmed' %} Savings Confirmed {% elif verified_data.status == 'negative' %} Costs Increased {% elif verified_data.status == 'collecting' %} Collecting Data {% elif verified_data.status == 'pending' %} Tracking Pending {% elif verified_data.status == 'insufficient_data' %} Insufficient Data {% endif %} {% endif %}
{# PR details - 2 column layout #}

Repository

{{ pr.repository }}

Branch

{{ pr.branch_name }}

Created

{{ pr.created_at.strftime('%d %b %Y %H:%M') if pr.created_at else '—' }}

Merged

{{ pr.merged_at.strftime('%d %b %Y %H:%M') if pr.merged_at else '—' }}

{# Lifecycle #}

Lifecycle

Created -> Open -> Verified -> Merged -> Savings collected

{% if pr.pr_url %} Open on GitHub {% endif %}
{% set lifecycle_verified = verified_data and verified_data.status in ['confirmed', 'negative'] %} {% set lifecycle_collecting = verified_data and verified_data.status in ['collecting', 'pending', 'insufficient_data'] %}

Created

{{ pr.created_at.strftime('%d %b %Y %H:%M') if pr.created_at else '—' }}

Open

{% if pr.status == 'open' %}Open{% else %}Archived{% endif %}

Verified

{% if lifecycle_verified %} {{ verified_data.status | replace('_', ' ') | title }} {% elif lifecycle_collecting %} {{ verified_data.status | replace('_', ' ') | title }} {% else %} Pending {% endif %}

Merged

{% if pr.merged_at %}Merged{% else %}Waiting{% endif %}

Savings Collected

{% if lifecycle_verified %} Collected {% elif lifecycle_collecting %} Collecting {% else %} Pending {% endif %}

{% if opportunity %} {# Linked opportunity #}

Linked Opportunity

{{ opportunity.opportunity_type | replace('_', ' ') | title }} {{ opportunity.affected_table }} {% if opportunity.dbt_model_name %} dbt: {{ opportunity.dbt_model_name }} {% endif %}
{% if config %} View opportunity details → {% endif %}
{% endif %} {% if verified_data and verified_data.status in ['confirmed', 'negative'] %} {# Verified savings metrics #}

Post-Merge Cost Verification

Pre-Merge Avg Cost

{% if verified_data.pre_merge_avg_cost is not none %} {{ verified_data.pre_merge_avg_cost | format_usd }} {% else %}—{% endif %}

{{ verified_data.pre_merge_job_count }} jobs

Post-Merge Avg Cost

{% if verified_data.post_merge_avg_cost is not none %} {{ verified_data.post_merge_avg_cost | format_usd }} {% else %}—{% endif %}

{{ verified_data.post_merge_job_count }} jobs

Verified Savings

{% if verified_data.verified_savings is not none %} {{ verified_data.verified_savings | format_usd }} {% else %}—{% endif %}

Per run

{% elif verified_data and verified_data.status == 'collecting' %}

Collecting post-merge job data. The cost verification chart will populate as new jobs run.

{% elif verified_data and verified_data.status == 'pending' %}

Cost tracking will begin after the next scheduled sync.

{% endif %} {% if verified_comparison %}

Verified Savings Comparison

Average BigQuery job cost before and after merge

{{ verified_data.status | replace('_', ' ') | title }}
{% endif %} {# ──────────────── Code Diff ──────────────── #}

Code Changes

{% if solution_diffs and solution_diffs | length > 0 %} {% for sol_diff in solution_diffs %}
{% set file_path = sol_diff.file_path %} {% set diff_lines = sol_diff.diff_lines %} {% include "components/code_diff.html" %}
{% endfor %} {% elif diff_error %}

Could not fetch diff from GitHub: {{ diff_error }}

View diff on GitHub instead
{% else %}

No code changes available for this PR.

{% endif %}
{# ──────────────── Downstream Lineage Impact ──────────────── #} {% if lineage_impact and lineage_impact.beneficiary_count > 0 %} {# Section A: Chain savings banner #}

Chain Savings {{ "PROJECTED" if lineage_impact.is_projected else "ESTIMATED" }}

{{ lineage_impact.total_estimated_savings | format_usd }}/month

across {{ lineage_impact.beneficiary_count }} downstream model{{ "s" if lineage_impact.beneficiary_count != 1 }} · {{ lineage_impact.change_type | title }} on {{ lineage_impact.affected_column }} in {{ lineage_impact.affected_model_name }}

{# Section B: Lineage tree (beneficiaries only) #} {% set beneficiaries = lineage_impact.results | selectattr("included") | list %} {% if beneficiaries %}

Downstream Lineage Tree

Models that benefit from {{ lineage_impact.change_type }} pruning, sorted by savings

{{ lineage_impact.beneficiary_count }} beneficiar{{ "y" if lineage_impact.beneficiary_count == 1 else "ies" }}
{# Tree rows — collapsed when many nodes #} {% set show_all = beneficiaries | length <= 5 %}
{% for r in beneficiaries %} {% set depth_pad = r.depth * 16 %}
{# Depth indicator #} {% if r.depth > 1 %} {% for _ in range(r.depth - 1) %}·{% endfor %}└ {% endif %}
{{ r.model_name }} {# Savings badge #} {% if r.estimated_monthly_cost_usd is not none %} {{ r.estimated_monthly_cost_usd | format_usd }}/mo {% endif %} {# Confidence pill #} {% if r.confidence %} {{ r.confidence }} {% endif %} {# Expression type chip #} {% if r.expression_type %} {{ r.expression_type }} {% endif %}
{# Breadcrumb path #}

{{ r.dependency_path | join(" → ") }}

{% endfor %}
{# "Show full chain" toggle when > 5 beneficiaries #} {% if beneficiaries | length > 5 %} {% endif %}
{% endif %} {# Section C: All downstream models accordion #} {% if lineage_impact.total_downstream_count > 0 %}
All {{ lineage_impact.total_downstream_count }} downstream model{{ "s" if lineage_impact.total_downstream_count != 1 }}
{% for r in lineage_impact.results %} {% endfor %}
Model Status Reason Savings/mo
{{ r.model_name }} d{{ r.depth }} {% if r.included %} ✓ Included {% else %} ✗ Excluded {% endif %} {{ r.inclusion_reason }} {% if r.estimated_monthly_cost_usd is not none %} {{ r.estimated_monthly_cost_usd | format_usd }} {% else %} {% endif %}
{% endif %} {% elif lineage_impact is defined and not lineage_impact %} {# lineage_impact explicitly None — section is hidden, no display needed #} {% endif %} {% if lineage_graph or (model_cost_trends and model_cost_trends | length > 0) or lineage_unavailable_reason %}
{% if lineage_graph %} {# ──────────────── Data Lineage ──────────────── #}

Data Lineage

Downstream lineage for the model changed by this PR. Upstream tables are omitted because their spend is not directly changed by this edit.

{{ lineage_graph.downstream_count }} downstream model{{ "s" if lineage_graph.downstream_count != 1 else "" }}
Changed model Downstream Scroll to pan · pinch/wheel to zoom
{% elif lineage_unavailable_reason %}

Data Lineage

dbt-style upstream and downstream lineage for the model changed by this PR

Unavailable

No lineage graph available

{{ lineage_unavailable_reason }}

{% if not pr.opportunity_id and not pr.solution_id %}

This PR is not linked to a Governor opportunity or solution, so the app cannot infer a model lineage or cost trend yet.

{% endif %}
{% endif %} {% if model_cost_trends and model_cost_trends | length > 0 %} {# ──────────────── Selected Cost Trend ──────────────── #}

Selected Model Cost Trend

Click a lineage node to inspect spend.

{{ model_cost_trends | length }} model{{ "s" if model_cost_trends | length != 1 else "" }}

Cost Trend

{% elif lineage_unavailable_reason %}

Selected Model Cost Trend

Cost history for the model changed by this PR

Unavailable

No cost trend available

{{ lineage_unavailable_reason }}

{% endif %}
{% endif %} {# ──────────────── Cost History Table ──────────────── #} {% if cost_history and cost_history | length > 0 %}

Cost History

{% if cost_history | length > 5 %} {{ cost_history | length }} runs · scroll to see earlier {% endif %}
{% if merged_at_str %} {% endif %} {% for row in cost_history %} {# Merge date divider row #} {% if row.is_merge_date %} {% endif %} {% if merged_at_str %} {% endif %} {% endfor %}
Run Time Run CostSaving Cumulative Savings
PR Merged — {{ merged_at_str }}
{{ row.date }} ${{ '%.2f' % row.cost }} {% if row.is_post_merge and row.saving is defined %} {{ '+' if row.saving >= 0 else '' }}${{ '%.2f' % row.saving }} {% else %} {% endif %} {% if row.is_post_merge and row.cumulative_savings is defined %} {{ '+' if row.cumulative_savings >= 0 else '' }}${{ '%.2f' % row.cumulative_savings }} {% else %} {% endif %}
{% endif %}
← Back to Pull Requests
{% if verified_comparison %} {% endif %} {% endblock %}