Skip to content

v3: start UK local-area breakdowns in the background, alongside the report run - #1434

Merged
PavelMakarchuk merged 2 commits into
mainfrom
feat/uk-v3-background-runs
Oct 27, 2026
Merged

PavelMakarchuk merged 2 commits into
mainfrom
feat/uk-v3-background-runs

Conversation

@PavelMakarchuk

Copy link
Copy Markdown
Contributor

Part of #1411. Follows #1427.

Summary

UK v3 reports start their local-area breakdown on their own. No click on "Compute local-area impacts" is needed.

  1. Start with the results (1a4b6e11b). This commit was meant for UK breakdowns: start in the background, poll through brief failures, time limit, measured estimate, nation withheld counts, map credit #1427 but was pushed after that PR merged, so it never reached main. UKLocalAreaAutoStart starts the breakdown when a UK-wide or nation report's national results come in without area impacts. It renders nothing; the Local areas tab follows the same run through the breakdown's query key and shows its progress, then the maps, or Retry after an error. The overview card now reads "They calculate in the background, in a few minutes."
  2. Start alongside the national run (d2bfa5a99). While the national run calculates, the report page shows its progress card instead of ReportView. That card now renders UKLocalAreaAutoStart with resultsRunning, so the breakdown request goes at the same moment as the national run.

What starts nothing:

  • results that already hold both area levels, and results from before .py 6.10.0;
  • household reports, and reports on one constituency or local authority;
  • a breakdown that failed (the tab offers Retry).

v2 is unchanged.

Checks

  • bunx tsc --noEmit, ESLint and Prettier pass.
  • Vitest: 194 related test files pass (1,903 tests). New: UKLocalAreaAutoStart.test.tsx (starts alongside a run; nothing without one; starts for results without areas; nothing for saved results with both levels or no version). Updated: the ReportView local-area tests now expect the request without a click.
  • Locally on localhost:3039 against the live API, new report 4827 (UC under-25 single allowance £320, 2026):
    • the breakdown=local_areas request started 1 ms after the national request, while the page showed "Calculating the UK-wide results";
    • it kept polling (29 requests) through the national run;
    • after the report opened, the Local areas tab showed "Computing local-area impacts…" with no Compute button, and then the maps once the run finished.

Cost

Every new UK-wide or nation report now also runs its breakdown (about 2½ to 4½ minutes of worker time; cached by the API after the first run). PolicyEngine/policyengine-sim-api#914 (baseline reuse) would cut about 50 s from each.

🤖 Generated with Claude Code

PavelMakarchuk and others added 2 commits October 27, 2026 09:06
UKLocalAreaAutoStart starts the breakdown run as soon as a UK-wide or
nation report's national result is in, instead of when the Local areas
tab's Compute button is clicked. It draws nothing: the tab follows the
same run through the breakdown's query key, so it shows the run's
progress, or the maps once the run completes, and Retry after an error.
A result that holds both levels, or one from before .py 6.10.0, starts
nothing, and a failed run is not started again by itself. The overview
card now says the impacts calculate in the background. v2 is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
While a UK-wide or nation report's national run calculates, the report
page shows its progress card instead of ReportView. That card now
renders UKLocalAreaAutoStart, which starts the breakdown at once,
alongside the national run, instead of after its results arrive. The
Local areas tab then follows the same run through the query key.
UKLocalAreaAutoStart takes the national results or null, with
resultsRunning for a run in progress; a report that opens from saved
results still starts the breakdown when they lack a level, as before.
Household reports and single-area reports start nothing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
policyengine-calculator-next Ready Ready Preview Oct 27, 2026 1:17pm UTC
policyengine-website Ready Ready Preview Oct 27, 2026 1:17pm UTC

Request Review

This branch was successfully deployed

2 active deployments
Preview – policyengine-website — d2bfa5a9 Deployed Oct 27, 2026 by vercel[bot]
Preview – policyengine-calculator-next — d2bfa5a9 Deployed Oct 27, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant