From 9e4cf9dfbfced3521501c3d4215ba39d10047439 Mon Sep 17 00:00:00 2001 From: Tudor Date: Wed, 1 Jul 2026 22:11:45 +0100 Subject: [PATCH] fix(ofsted): apply ungraded fallback on school detail page too The detail page reads overall_effectiveness from the API and showed "Not rated" for ungraded-only schools, even though the list badge uses the coalesced grade. Coalesce the ungraded fallback into the API's overall_effectiveness so the detail page shows the same grade. Co-Authored-By: Claude Opus 4.8 --- backend/data_loader.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/backend/data_loader.py b/backend/data_loader.py index ce51ab1..60883f2 100644 --- a/backend/data_loader.py +++ b/backend/data_loader.py @@ -416,7 +416,14 @@ def get_supplementary_data(db: Session, urn: int) -> dict: "framework": o.framework, "inspection_date": o.inspection_date.isoformat() if o.inspection_date else None, "inspection_type": o.inspection_type, - "overall_effectiveness": o.overall_effectiveness, + # Fall back to the grade parsed from an ungraded (Section 8) outcome + # (e.g. "School remains Good") when there's no graded grade, so the + # detail page matches the list badge. + "overall_effectiveness": ( + o.overall_effectiveness + if o.overall_effectiveness is not None + else o.ungraded_grade + ), "quality_of_education": o.quality_of_education, "behaviour_attitudes": o.behaviour_attitudes, "personal_development": o.personal_development,