feat(pipeline): one current Ofsted status per school (C1/M1, part 1 of 2) #183

Merged
tudor merged 7 commits from fix/ofsted-current-status-pipeline into main 2026-10-05 15:44:59 +00:00
2 changed files with 8 additions and 6 deletions
Showing only changes of commit 480ac4b9a9 - Show all commits

No files matched your search

@@ -17,7 +17,7 @@
- PR 2 must not be merged before `school_data_monthly_ofsted` has run on staging with PR 1, nor promoted before it has run on production.
- No compatibility code in the backend for marts built before PR 1 (agreed in brainstorming).
- Copy follows the site's factual rule: print what Ofsted published; no derived summaries. Dates in prose use long months ("14 March 2023").
- Commits end with `Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>`; PR bodies end with the Claude Code line. Never push to `main`.
- Commits end with the Co-Authored-By trailer the executing session's harness specifies (not a fixed model name); PR bodies end with the Claude Code line. Never push to `main`.
## Review Focus
@@ -289,7 +289,7 @@ Expected: unit tests PASS; `fact_ofsted_inspection`'s `not_null` on `inspection_
```bash
git add pipeline/transform/models/staging/stg_ofsted_inspections.sql pipeline/transform/models/staging/stg_ofsted_inspections.yml
git commit -m "feat(pipeline): keep Ofsted's graded, ungraded and report-card dates apart" -m "int_ofsted_latest needs to know which inspection came last. Report-card-only schools are no longer dropped; inspection_date stays for current readers and now falls back to the report-card date." -m "Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>"
git commit -m "feat(pipeline): keep Ofsted's graded, ungraded and report-card dates apart" -m "int_ofsted_latest needs to know which inspection came last. Report-card-only schools are no longer dropped; inspection_date stays for current readers and now falls back to the report-card date." -m "<the session's Co-Authored-By trailer>"
```
### Task 3: `int_ofsted_latest` computes the current status
@@ -81,10 +81,12 @@ Computed once per URN in `int_ofsted_latest`.
| Latest is ungraded, any other outcome ("Standards maintained", "Improved significantly", "Some aspects not as strong") | the graded inspection's overall grade if it is 1–4, else null | G when a grade is kept | `graded` when a grade is kept |
| No inspection | null | null | null |
Report cards began in November 2025, after the last legacy graded and ungraded
inspections, so when a school has a report card it is always the latest visit,
and no legacy grade stays in force beside it. Ties between G, U and RC on the
same date resolve in the order report card, graded, ungraded.
A report card replaced overall grades, so no legacy grade stays in force beside
one. The latest visit is read from the dates, not assumed: report cards began in
November 2025, after the last legacy graded and ungraded inspections, and in
Ofsted's 31 Aug 2026 data no school has a legacy visit newer than its report
card, but the rule does not depend on that. Ties between G, U and RC on the same
date resolve in the order report card, graded, ungraded.
Invariants: `current_grade` is null or 1–4; `current_grade_date <=
latest_visit_date`; `current_grade_basis` is null exactly when `current_grade`