feat(admissions): show the last distance offered where councils publish it
PR Checks / Frontend Typecheck + Tests (pull_request) Successful in 1m3s
PR Checks / Backend Smoke (pull_request) Successful in 7s
PR Checks / Build Backend (no push) (pull_request) Successful in 31s
PR Checks / Build Frontend (no push) (pull_request) Successful in 44s
PR Checks / Build Pipeline (no push) (pull_request) Successful in 1m12s
PR Checks / AI Code Review (Claude) (pull_request) Failing after 2m7s

Adds the cut-off distance a parent actually asks about — "how close do we
need to live?" — end to end: a Singer tap, dbt staging and mart models, an
Airflow DAG, and a tile on both detail templates. 3,597 schools across 57
local authorities carry a figure; the rest are unchanged.

There is no national source for this. Each LA publishes its own cut-offs in
its own format, and the collected CSV is transcribed from PDFs, spreadsheets
and web pages — so most of the work here is deciding what is safe to show.

Data
  * tap-uk-school-distance loads the CSV verbatim into raw. Keyed on
    (urn, year, school_name), because school_name carries the admission
    route: (urn, year) alone collides on 118 keys and a reload would have
    silently dropped every band but one.
  * stg_school_distance applies a 25 m – 25 km plausibility band. The source
    contains 0.0-mile rows (published where a school filled on a higher
    criterion), 1-metre cut-offs, and one reading 533 miles — ~4% of rows,
    all of which would put a visibly wrong number on a live page.
  * fact_admission_distance collapses routes to one row per school per year
    using the furthest, and keeps route_count so the page can say the figure
    is the widest of several bands rather than the one for a given child.

Serving
  * Kept out of fact_admissions: that mart is EES-derived and near-complete
    for England, this one covers 57 LAs, and the two refresh independently.
  * Latest year only. Coverage is ragged — a school may have 2021 and 2026
    and nothing between — so a history array would invite a trend line drawn
    through gaps that are absences of publication, not of a cut-off.
  * The Admissions section now renders on either source. 3% of the schools
    that render have a cut-off and no EES admissions row, and gating on
    admissions alone would have hidden the figure on those pages.

Interface
  * The year travels with the figure everywhere it appears; a cut-off
    detached from its admissions round is not a fact about anything.
  * "Not a fixed catchment — it moves every year" sits under every instance,
    because that is the inference a parent will otherwise draw.
  * Replaces a hardcoded "Historical distance cut-off data is not available
    for this school" that appeared on every secondary page, including the
    ones whose council does publish it. The absence is now stated only when
    it is real, and names the authority that would hold it.

The tint costs the muted tokens their AA margin: measured on the composited
backdrop (not the computed one, which reports the untinted card), --text-muted
falls to 4.09:1 in dark theme. The tile uses --text-secondary instead — 6.50:1
dark, 6.60:1 light.

The DAG is manual, like the other annual ones: councils publish on allocation
day, each on its own timetable, so there is no date worth scheduling against.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WDvkyqqHABm4bmth2kjAxE
This commit is contained in:
TudorandClaude Opus 5 committed 2026-08-15 22:48:30 +01:00
1 parent 5156a85bd1
commit 88c653215d
31 files changed
+1753 -42

No files matched your search

@@ -778,6 +778,38 @@
word-break: break-word;
}
/* Last distance offered, secondary template. These cards are opaque
(--bg-secondary), so the tint can be set directly here — unlike the primary
tile grid, nothing shows through between them. */
.metricCardDistance {
background-color: var(--bg-card);
background-image: linear-gradient(var(--brand-bg), var(--brand-bg));
border-color: var(--brand);
/* Two columns' worth of width. Its label carries the entry year as well as
the measure, which at the 140px track width of the other cards wraps to
three lines and pushes the figure out of alignment with them. */
grid-column: span 2;
}
.metricCardDistance .metricValue {
flex-direction: column;
gap: 0.1rem;
color: var(--brand-strong);
}
.metricValueSub {
font-size: 0.75rem;
font-weight: 500;
color: var(--text-muted);
}
/* Same measured reason as .admissionsTileDistance above: --text-muted falls to
4.09:1 on the tinted card in dark theme. */
.metricCardDistance .metricLabel,
.metricCardDistance .metricValueSub {
color: var(--text-secondary);
}
.metricHint {
font-size: 0.7rem;
color: var(--text-muted);
@@ -1453,6 +1485,62 @@
color: var(--brand-strong);
}
/* ── Admissions: last distance offered ──
*
* Spans the full grid width instead of taking a fifth half-cell. Two reasons:
* the tiles are a 2-column grid, so a fifth tile would sit alone next to a gap;
* and this is the figure the section is most often opened for, which a
* half-width cell would rank below "Applied in total".
*/
.admissionsTileDistance {
grid-column: 1 / -1;
/*
* --brand-bg is translucent, and the tile grid paints --border between
* cells, so a plain `background` would let the hairline colour show through
* and read as muddy rather than tinted. The opaque card colour is laid down
* first and the tint composited over it as an image.
*/
background-color: var(--bg-card);
background-image: linear-gradient(var(--brand-bg), var(--brand-bg));
}
.admissionsTileDistance .admissionsTileNum {
color: var(--brand-strong);
}
/*
* The tint costs the muted tokens their AA margin, so this tile does not use
* them.
*
* Measured on the composited backdrop, not the computed one: the tint is a
* background-image over --bg-card, so getComputedStyle reports the untinted
* card and flatters the result. Sampling the rendered pixel in dark theme gives
* a backdrop of rgb(34,59,64), on which --text-muted is 4.09:1 — under the 4.5
* floor — while --text-secondary is 6.50:1.
*
* The label is where the year lives, so it is the last thing on the tile that
* can afford to be hard to read: a distance without its year is not a fact
* about anything.
*/
.admissionsTileDistance .admissionsTileLabel,
.admissionsTileDistance .admissionsTileSub {
color: var(--text-secondary);
}
/*
* The caveats, not a footnote in the visual-noise sense: without them the
* figure reads as a catchment boundary. Kept at body contrast rather than
* --text-muted for that reason — it qualifies the number above it, so it has
* to be as readable as the number.
*/
.admissionsDistanceNote {
margin: 0.85rem 0 0;
font-size: 0.8125rem;
line-height: 1.55;
color: var(--text-secondary);
max-width: 68ch;
}
.admissionsVerdict {
margin-top: 0.75rem;
margin-bottom: 0.25rem;
@@ -1568,6 +1656,20 @@
grid-template-rows: 1fr 1fr;
}
/* The distance tile occupies a third row. Left implicit it would inherit the
1fr sizing of the row template and stretch to match the metric tiles above,
which are twice its content height. */
.admissionsViewYear .admissionsTilesWithDistance {
grid-template-rows: 1fr 1fr auto;
}
/* Cut-off distance but no EES admissions figures: there is nothing to put in
the two metric rows, and leaving them in the template paints an empty block
of the grid's gap colour beneath the tile. */
.admissionsViewYear .admissionsTilesDistanceOnly {
grid-template-rows: auto;
}
.admissionsChartCap {
font-size: 0.8125rem;
font-weight: 600;