Applying compare-screen teaching #1 (report-card dating) to the detail page — which turned out to be a bigger bug than just the date.
What was wrong
Both detail views (SchoolDetailView, SecondarySchoolDetailView) detected report cards with ofsted.framework === 'ReportCard'. But the API sets framework to the raw event grouping ("Schools - S5") even for report-card schools, so that test never matched. Consequences on the live detail page:
Report-card schools rendered as legacy "Ofsted Rating" badges, not report cards.
Dated with the legacy inspection_date. Barclay Primary showed "Ofsted Rating: Outstanding, Inspected 7 October 2021" — its carried-forward legacy grade — instead of its real February 2026 report card.
So the report-card dating bug (compare teaching #1) was a symptom: you can't date a report card the detail page never detects. Fixing the date required fixing detection, which also absorbs teaching #3 (regime detection) for the report-card case.
Fix
Detect report cards by the presence of the report_card object (the robust signal the compare screen already uses), not framework.
Date report cards with rc_inspection_date; keep inspection_date for legacy ratings. A report card is never shown with a pre-Nov-2025 date.
Both primary and secondary detail views.
Verification
New e2e journey visits a real report-card school (Barclay 138690), asserts the section renders as "Ofsted Report Card" and is dated to the report-card inspection year, not the legacy one — robust to future re-inspection (it reads both dates from the API). tsc + 101 frontend unit tests green.
Related follow-up (NOT in this PR)
The list/map surface has the same latent bug: LeafletMapInner checks school.ofsted_framework === 'ReportCard', and that field is also "Schools - S5" — so map pins/list markers label report-card schools by their old grade (Barclay's pin shows Outstanding). Same root cause, separate surface; worth a follow-up.
Applying compare-screen teaching #1 (report-card dating) to the detail page — which turned out to be a bigger bug than just the date.
## What was wrong
Both detail views (`SchoolDetailView`, `SecondarySchoolDetailView`) detected report cards with `ofsted.framework === 'ReportCard'`. But the API sets `framework` to the **raw event grouping** (`"Schools - S5"`) even for report-card schools, so that test **never matched**. Consequences on the live detail page:
- Report-card schools rendered as legacy **"Ofsted Rating"** badges, not report cards.
- Dated with the legacy `inspection_date`. Barclay Primary showed **"Ofsted Rating: Outstanding, Inspected 7 October 2021"** — its carried-forward legacy grade — instead of its real **February 2026 report card**.
So the report-card dating bug (compare teaching #1) was a symptom: you can't date a report card the detail page never detects. Fixing the date required fixing detection, which also absorbs teaching #3 (regime detection) for the report-card case.
## Fix
- Detect report cards by the presence of the `report_card` object (the robust signal the compare screen already uses), not `framework`.
- Date report cards with `rc_inspection_date`; keep `inspection_date` for legacy ratings. A report card is never shown with a pre-Nov-2025 date.
- Both primary and secondary detail views.
## Verification
New e2e journey visits a real report-card school (Barclay 138690), asserts the section renders as **"Ofsted Report Card"** and is dated to the report-card inspection year, not the legacy one — robust to future re-inspection (it reads both dates from the API). tsc + 101 frontend unit tests green.
## Related follow-up (NOT in this PR)
The list/map surface has the **same** latent bug: `LeafletMapInner` checks `school.ofsted_framework === 'ReportCard'`, and that field is also `"Schools - S5"` — so map pins/list markers label report-card schools by their old grade (Barclay's pin shows Outstanding). Same root cause, separate surface; worth a follow-up.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_0146VHeLAWjDVE2B5uU67jCB
The detail views detected report cards via ofsted.framework === 'ReportCard',
but the API sets framework to the raw event grouping ('Schools - S5') even
for report-card schools — so the check never matched: report-card schools
rendered as legacy 'Ofsted Rating' badges dated to a pre-Nov-2025
inspection (e.g. Barclay shown as 'Outstanding, Inspected 7 October 2021'
instead of its Feb 2026 report card).
Detect report cards by the presence of the report_card object (matching
the compare screen), and date them with rc_inspection_date, never the
legacy inspection_date. Applies to both primary and secondary detail views.
New e2e assertion against a real report-card school gates it.
Note: the list/map surface has the same latent issue via ofsted_framework
(LeafletMapInner) — flagged as a separate follow-up.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0146VHeLAWjDVE2B5uU67jCB
This PR fixes Ofsted report-card detection to key off the presence of ofsted.report_card entries rather than the never-matching framework === 'ReportCard' check, and dates report-card schools using rc_inspection_date instead of the legacy inspection_date, applied consistently across both primary and secondary detail views (matching the pattern already used in the compare views). An e2e test is added to verify the fix end-to-end, and the referenced report_card/rc_inspection_date fields are already present in the shared types. The change is small, self-contained, well-tested, and consistent with existing conventions.
✅ No issues found.
## 🤖 AI Code Review (Claude Code)
This PR fixes Ofsted report-card detection to key off the presence of `ofsted.report_card` entries rather than the never-matching `framework === 'ReportCard'` check, and dates report-card schools using `rc_inspection_date` instead of the legacy `inspection_date`, applied consistently across both primary and secondary detail views (matching the pattern already used in the compare views). An e2e test is added to verify the fix end-to-end, and the referenced `report_card`/`rc_inspection_date` fields are already present in the shared types. The change is small, self-contained, well-tested, and consistent with existing conventions.
✅ No issues found.
tudor
merged commit 74bdbebd57 into main2026-07-18 18:13:26 +00:00
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Applying compare-screen teaching #1 (report-card dating) to the detail page — which turned out to be a bigger bug than just the date.
What was wrong
Both detail views (
SchoolDetailView,SecondarySchoolDetailView) detected report cards withofsted.framework === 'ReportCard'. But the API setsframeworkto the raw event grouping ("Schools - S5") even for report-card schools, so that test never matched. Consequences on the live detail page:inspection_date. Barclay Primary showed "Ofsted Rating: Outstanding, Inspected 7 October 2021" — its carried-forward legacy grade — instead of its real February 2026 report card.So the report-card dating bug (compare teaching #1) was a symptom: you can't date a report card the detail page never detects. Fixing the date required fixing detection, which also absorbs teaching #3 (regime detection) for the report-card case.
Fix
report_cardobject (the robust signal the compare screen already uses), notframework.rc_inspection_date; keepinspection_datefor legacy ratings. A report card is never shown with a pre-Nov-2025 date.Verification
New e2e journey visits a real report-card school (Barclay 138690), asserts the section renders as "Ofsted Report Card" and is dated to the report-card inspection year, not the legacy one — robust to future re-inspection (it reads both dates from the API). tsc + 101 frontend unit tests green.
Related follow-up (NOT in this PR)
The list/map surface has the same latent bug:
LeafletMapInnerchecksschool.ofsted_framework === 'ReportCard', and that field is also"Schools - S5"— so map pins/list markers label report-card schools by their old grade (Barclay's pin shows Outstanding). Same root cause, separate surface; worth a follow-up.🤖 Generated with Claude Code
https://claude.ai/code/session_0146VHeLAWjDVE2B5uU67jCB
The detail views detected report cards via ofsted.framework === 'ReportCard', but the API sets framework to the raw event grouping ('Schools - S5') even for report-card schools — so the check never matched: report-card schools rendered as legacy 'Ofsted Rating' badges dated to a pre-Nov-2025 inspection (e.g. Barclay shown as 'Outstanding, Inspected 7 October 2021' instead of its Feb 2026 report card). Detect report cards by the presence of the report_card object (matching the compare screen), and date them with rc_inspection_date, never the legacy inspection_date. Applies to both primary and secondary detail views. New e2e assertion against a real report-card school gates it. Note: the list/map surface has the same latent issue via ofsted_framework (LeafletMapInner) — flagged as a separate follow-up. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0146VHeLAWjDVE2B5uU67jCB🤖 AI Code Review (Claude Code)
This PR fixes Ofsted report-card detection to key off the presence of
ofsted.report_cardentries rather than the never-matchingframework === 'ReportCard'check, and dates report-card schools usingrc_inspection_dateinstead of the legacyinspection_date, applied consistently across both primary and secondary detail views (matching the pattern already used in the compare views). An e2e test is added to verify the fix end-to-end, and the referencedreport_card/rc_inspection_datefields are already present in the shared types. The change is small, self-contained, well-tested, and consistent with existing conventions.✅ No issues found.