diff --git a/backend/app.py b/backend/app.py index ba02671..4e30a5e 100644 --- a/backend/app.py +++ b/backend/app.py @@ -15,12 +15,7 @@ from typing import Optional import os import re -# Local Authority codes for Wandsworth and Merton -LA_CODES = { - 212: "Wandsworth", - 315: "Merton" -} -ALLOWED_LA_CODES = list(LA_CODES.keys()) +# No longer filtering by specific LA codes - load all available schools app = FastAPI( title="SchoolCompare API", @@ -128,21 +123,22 @@ def load_school_data() -> pd.DataFrame: print(f"Loading data from {ks2_file}") df = pd.read_csv(ks2_file, low_memory=False) - # Filter to Wandsworth (212) and Merton (315) # Handle both string and integer columns - if df['LEA'].dtype == 'object': + if 'LEA' in df.columns and df['LEA'].dtype == 'object': df['LEA'] = pd.to_numeric(df['LEA'], errors='coerce') - if df['URN'].dtype == 'object': + if 'URN' in df.columns and df['URN'].dtype == 'object': df['URN'] = pd.to_numeric(df['URN'], errors='coerce') - df = df[df['LEA'].isin(ALLOWED_LA_CODES)] # Filter to schools only (RECTYPE == 1 means school level data) if 'RECTYPE' in df.columns: df = df[df['RECTYPE'] == 1] - # Add year and local authority name + # Add year and local authority name from LANAME column df['year'] = year - df['local_authority'] = df['LEA'].map(LA_CODES) + if 'LANAME' in df.columns: + df['local_authority'] = df['LANAME'] + elif 'LEA' in df.columns: + df['local_authority'] = df['LEA'].astype(str) # Standardize column names for our API df = df.rename(columns={ @@ -380,7 +376,7 @@ async def get_filter_options(): if df.empty: return { - "local_authorities": ["Wandsworth", "Merton"], + "local_authorities": [], "school_types": [], "years": [], } diff --git a/frontend/app.js b/frontend/app.js index 1961f3a..c1c07b6 100644 --- a/frontend/app.js +++ b/frontend/app.js @@ -78,6 +78,14 @@ async function loadFilters() { const data = await fetchAPI('/api/filters'); if (!data) return; + // Populate local authority filter + data.local_authorities.forEach(la => { + const option = document.createElement('option'); + option.value = la; + option.textContent = la; + elements.localAuthorityFilter.appendChild(option); + }); + // Populate school type filter data.school_types.forEach(type => { const option = document.createElement('option'); diff --git a/frontend/index.html b/frontend/index.html index bcc2725..5c27a24 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -41,7 +41,7 @@

Compare Primary School Performance

-

Explore and compare KS2 results across Wandsworth & Merton primary schools

+

Explore and compare KS2 results across England's primary schools

@@ -57,8 +57,6 @@