fix(pipeline): read the latest Ofsted visit from the dates

int_ofsted_latest treated any report card as the latest visit, relying on report cards postdating legacy inspections. That holds today (0 of 2,451 report-card schools in the 31 Aug 2026 MI) but is now not assumed: the latest visit is the newest of the three dates. A report card still leaves no legacy grade in force, which is the spec's rule rather than an inference. New unit test newer_legacy_visit_after_a_report_card failed RED on the old logic. Review on #183.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
TudorandClaude Opus 5.5 committed 2026-10-05 16:39:24 +01:00
1 parent dfa4928641
commit 93f17211b1
3 files changed
+26 -9

No files matched your search

@@ -7,4 +7,4 @@ from {{ ref('fact_ofsted_latest') }}
where current_grade_date > latest_visit_date
or (current_grade is null) <> (current_grade_date is null)
or (current_grade is null) <> (current_grade_basis is null)
or (latest_visit_kind = 'report_card' and current_grade is not null)
or (rc_inspection_date is not null and current_grade is not null)