fix(admissions): correct first_preference_offer_pct in dbt staging
Build and Push Docker Images / Build Backend (FastAPI) (push) Successful in 18s
Build and Push Docker Images / Build Frontend (Next.js) (push) Successful in 49s
Build and Push Docker Images / Build Pipeline (Meltano + dbt + Airflow) (push) Successful in 1m12s
Build and Push Docker Images / Trigger Portainer Update (push) Successful in 1s

The staging model was mapping EES column ``proportion_1stprefs_v_totaloffers``
straight onto ``first_preference_offer_pct``. That raw column is not a
percentage — it is a ratio of first-preference applications to total offers
(an oversubscription indicator, >1 means oversubscribed), so OLQH rendered
as "1%" when the true first-choice success rate is 27/42 = 64%.

The frontend display code is not at fault and is not patched here —
data-quality issues must be fixed at the source.

- stg_ees_admissions: compute ``first_preference_offer_pct`` as
  ``100 * number_1st_preference_offers / times_put_as_1st_preference`` —
  of families who listed this school first, the % that received an offer
  (0–100). Guard against divide-by-zero.
- stg_ees_admissions: expose the legitimate EES ratio as the new column
  ``oversubscription_ratio`` (1st-preference applications per place) for
  future use, clearly named.
- fact_admissions, FactAdmissions model, data_loader: propagate the new
  ``oversubscription_ratio`` column.
- SchoolAdmissions type: document both columns inline.
- buildSchoolSummary: reword the oversubscription clause so it reads
  sensibly across the whole 0–100 range (no more "just 64%").
- Hero chip subtitle: clearer phrasing "X% of first-choice applicants
  offered a place".

Requires a dbt run of stg_ees_admissions and fact_admissions on deploy
so the new column materialises.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Tudor Sitaru
2026-04-08 11:29:40 +01:00
parent 3458195865
commit 1e5c66d6ab
7 changed files with 29 additions and 4 deletions
@@ -9,6 +9,7 @@ select
first_preference_applications,
first_preference_offers,
first_preference_offer_pct,
oversubscription_ratio,
oversubscribed,
admissions_policy
from {{ ref('stg_ees_admissions') }}
@@ -29,7 +29,25 @@ renamed as (
{{ safe_numeric('times_put_as_1st_preference') }}::integer as first_preference_applications,
-- Proportions
{{ safe_numeric('proportion_1stprefs_v_totaloffers') }} as first_preference_offer_pct,
-- first_preference_offer_pct: of families who listed this school FIRST,
-- the percentage that received an offer. 0100 scale.
-- The raw EES column `proportion_1stprefs_v_totaloffers` stores a
-- different, misleading figure (first-preference applications divided
-- by total offers, i.e. an oversubscription ratio) — do not use it.
case
when {{ safe_numeric('times_put_as_1st_preference') }} > 0
then 100.0
* {{ safe_numeric('number_1st_preference_offers') }}
/ {{ safe_numeric('times_put_as_1st_preference') }}
end as first_preference_offer_pct,
-- Oversubscription ratio: 1st-preference applications per place offered.
-- >1 means the school is oversubscribed on first preferences.
case
when {{ safe_numeric('total_number_places_offered') }} > 0
then {{ safe_numeric('times_put_as_1st_preference') }}::numeric
/ {{ safe_numeric('total_number_places_offered') }}
end as oversubscription_ratio,
-- Derived: oversubscribed if 1st-preference applications > places offered
-- Use already-cast columns to avoid repeating the regex expression