fix(pipeline): dim_school's Ofsted grade is the one still in force

dim_school.ofsted_grade (Typesense's rating) coalesced the graded grade with an older ungraded visit's, so Rabbsfarm's 2020 'remains Good' survived its 2025 no-grade inspection. It now reads int_ofsted_latest's current_grade, and ofsted_date is the latest visit. Unit tests pin both (audit C1, M1).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
TudorandClaude Opus 5.5 committed 2026-10-05 16:26:51 +01:00
1 parent befaf950a7
commit 96732c56d1
2 files changed
+40 -5

No files matched your search

@@ -71,12 +71,12 @@ select
s.nursery_provision,
s.admissions_policy_code,
-- Latest Ofsted (populated after monthly Ofsted pipeline runs)
-- Latest Ofsted (populated after monthly Ofsted pipeline runs). The grade
-- still in force and the latest visit, from int_ofsted_latest — never a
-- grade carried past a newer inspection.
{% if ofsted_relation is not none %}
-- Prefer the graded overall effectiveness; fall back to the grade parsed
-- from the latest ungraded (Section 8) outcome when no graded grade exists.
coalesce(o.overall_effectiveness, o.ungraded_grade) as ofsted_grade,
o.inspection_date as ofsted_date,
o.current_grade as ofsted_grade,
o.latest_visit_date as ofsted_date,
o.framework as ofsted_framework
{% else %}
null::text as ofsted_grade,