fix(detail): render & correctly date Ofsted report cards #62

Merged
tudor merged 1 commits from fix/detail-report-card-render-date into main 2026-07-18 18:13:26 +00:00
Owner

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.ai/code/session_0146VHeLAWjDVE2B5uU67jCB

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
tudor added 1 commit 2026-07-18 18:09:39 +00:00
fix(detail): render report cards and date them by the report-card inspection
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 11s
PR Checks / Build Frontend (no push) (pull_request) Successful in 55s
PR Checks / Build Pipeline (no push) (pull_request) Successful in 10s
PR Checks / AI Code Review (Claude) (pull_request) Successful in 1m2s
b31e71ac88
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_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 main 2026-07-18 18:13:26 +00:00
Sign in to join this conversation.
No Reviewers
No labels
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: tudor/school_compare#62