feat(admissions): publish the latest cut-off only, holding history back
PR Checks / Frontend Typecheck + Tests (pull_request) Successful in 1m4s
PR Checks / Backend Smoke (pull_request) Successful in 7s
PR Checks / Build Backend (no push) (pull_request) Successful in 16s
PR Checks / Build Frontend (no push) (pull_request) Successful in 45s
PR Checks / Build Pipeline (no push) (pull_request) Successful in 11s
PR Checks / AI Code Review (Claude) (pull_request) Failing after 3m17s
PR Checks / Frontend Typecheck + Tests (pull_request) Successful in 1m4s
PR Checks / Backend Smoke (pull_request) Successful in 7s
PR Checks / Build Backend (no push) (pull_request) Successful in 16s
PR Checks / Build Frontend (no push) (pull_request) Successful in 45s
PR Checks / Build Pipeline (no push) (pull_request) Successful in 11s
PR Checks / AI Code Review (Claude) (pull_request) Failing after 3m17s
Earlier years are to become a paid feature, so they stop being published.
The load-bearing part is that this is a change to the API, not only to the
page. /api/schools/{urn} is public and unauthenticated: leaving
admission_distance_history in the payload while declining to render it would
have handed the whole record to anyone who opened the network tab. It is
withheld at the source, and the page follows.
Nothing changes upstream. The tap, the plausibility band and
fact_admission_distance are untouched and still load every published year, so
restoring history for entitled callers is a change to one function in
data_loader rather than a re-collection.
What the reader now gets is the latest figure on the Admissions tile, and a
Distance section that answers the question the number alone cannot: whether
their own address falls inside it. Retitled to "How far away are you?", which
is what it now does — the previous title described a record that is no longer
there.
Removed with the history: the trend chart, the year-by-year table, the
per-year verdict strip, the trend summary and the coverage note, along with
their CSS. The section goes from 743px to 417px.
One consequence worth naming. A run of years used to soften a single close
call — a home just outside one year's cut-off was usually inside another. With
one year published, the "too close to call" band is the entire safety margin
between a parent and a place they do not have, so the verdict now names its
year, and the three outcomes are tinted apart rather than distinguished by
wording alone.
The existing stylesheet test earned its keep here: the three verdict classes
were referenced before they were written, and it caught them. Unstyled, a
"beyond the cut-off" result would have been indistinguishable from an "inside"
one — the exact failure the longhand class map was written to prevent.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WDvkyqqHABm4bmth2kjAxE
This commit is contained in:
1 parent
50b599a09b
commit
c9a1892bfb
20 files changed
+382
-1215
No files matched your search
+16
-16
@@ -771,7 +771,6 @@ def _empty_supplementary() -> dict:
|
||||
"admissions": None,
|
||||
"admissions_history": [],
|
||||
"admission_distance": None,
|
||||
"admission_distance_history": [],
|
||||
"sen_detail": None,
|
||||
"phonics": None,
|
||||
"deprivation": None,
|
||||
@@ -850,29 +849,30 @@ def get_supplementary_data_batch(db: Session, urns: list[int]) -> dict:
|
||||
result[urn]["admissions"] = rows_for_urn[-1] if rows_for_urn else None
|
||||
_safe(_admissions)
|
||||
|
||||
# Last distance offered — all years per URN, oldest first, with the latest
|
||||
# also exposed on its own.
|
||||
# Last distance offered — the latest year per URN, and only that.
|
||||
#
|
||||
# The history was deliberately withheld at first: coverage is ragged (a
|
||||
# school may have 2021 and 2026 and nothing between), and a plain series
|
||||
# would draw a trend line straight through gaps that are absences of
|
||||
# publication rather than absences of a cut-off. It is served now because
|
||||
# the client distinguishes those gaps explicitly — see cutoffYearRows in
|
||||
# lastDistanceOffered.ts, which classifies every year in the range and
|
||||
# breaks the line rather than interpolating across it.
|
||||
# The mart holds every published year and the DAG keeps loading them; what
|
||||
# changed is what leaves this process. Earlier years are being held back as
|
||||
# a paid feature, and this API is public and unauthenticated — serving the
|
||||
# history here would hand it to anyone who opened the network tab, whatever
|
||||
# the page chose to render. Withholding it in the client would have been
|
||||
# decoration, not a decision.
|
||||
#
|
||||
# Restoring it for entitled callers is a change to this function, not to
|
||||
# the pipeline: fact_admission_distance is untouched and complete.
|
||||
def _admission_distance():
|
||||
rows = (
|
||||
db.query(FactAdmissionDistance)
|
||||
.filter(FactAdmissionDistance.urn.in_(urns))
|
||||
.order_by(FactAdmissionDistance.urn, FactAdmissionDistance.year.asc())
|
||||
.order_by(FactAdmissionDistance.urn, FactAdmissionDistance.year.desc())
|
||||
.all()
|
||||
)
|
||||
history: dict = {urn: [] for urn in urns}
|
||||
seen = set()
|
||||
for d in rows:
|
||||
history[d.urn].append(_admission_distance_dict(d))
|
||||
for urn, rows_for_urn in history.items():
|
||||
result[urn]["admission_distance_history"] = rows_for_urn
|
||||
result[urn]["admission_distance"] = rows_for_urn[-1] if rows_for_urn else None
|
||||
if d.urn in seen:
|
||||
continue
|
||||
seen.add(d.urn)
|
||||
result[d.urn]["admission_distance"] = _admission_distance_dict(d)
|
||||
_safe(_admission_distance)
|
||||
|
||||
# Deprivation — one row per URN.
|
||||
|
||||
Reference in new issue
Block a user