fix(compare): census-sourced FSM/EAL benchmarks; never fall back across measure definitions

The FSM chip anchored against disadvantaged_pct (a different measure,
FSM6+CLA) whenever fsm_pct was null — which it always was, since the
performance df has no fsm_pct. New fact_census_benchmarks mart supplies
pupil-weighted FSM/EAL means per phase; the KS2-column medians that
produced a bogus 50% 'secondary disadvantaged' anchor are gone.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0146VHeLAWjDVE2B5uU67jCB
This commit is contained in:
Tudor
2026-07-16 19:05:15 +01:00
co-authored by Claude Fable 5
parent 9773483221
commit 1d855f3c17
7 changed files with 142 additions and 24 deletions
+16
View File
@@ -234,6 +234,22 @@ class FactFinance(Base):
premises_cost_pct = Column(Float)
class CensusBenchmark(Base):
"""State-school context benchmarks from the pupil census — one row per phase.
fsm_pct / eal_pct are pupil-weighted means. Computed at import time;
consumers label them "state-school average (computed from our dataset)".
"""
__tablename__ = "fact_census_benchmarks"
__table_args__ = MARTS
phase = Column(String(20), primary_key=True)
year = Column(Integer)
fsm_pct = Column(Float)
eal_pct = Column(Float)
median_pupils = Column(Integer)
class Ks4NationalAverage(Base):
"""Computed national KS4 averages (from our dataset) — one row per year."""
__tablename__ = "fact_ks4_national_averages"