Including all schools in England
All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 58s
All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 58s
This commit is contained in:
@@ -15,12 +15,7 @@ from typing import Optional
|
|||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
|
||||||
# Local Authority codes for Wandsworth and Merton
|
# No longer filtering by specific LA codes - load all available schools
|
||||||
LA_CODES = {
|
|
||||||
212: "Wandsworth",
|
|
||||||
315: "Merton"
|
|
||||||
}
|
|
||||||
ALLOWED_LA_CODES = list(LA_CODES.keys())
|
|
||||||
|
|
||||||
app = FastAPI(
|
app = FastAPI(
|
||||||
title="SchoolCompare API",
|
title="SchoolCompare API",
|
||||||
@@ -128,21 +123,22 @@ def load_school_data() -> pd.DataFrame:
|
|||||||
print(f"Loading data from {ks2_file}")
|
print(f"Loading data from {ks2_file}")
|
||||||
df = pd.read_csv(ks2_file, low_memory=False)
|
df = pd.read_csv(ks2_file, low_memory=False)
|
||||||
|
|
||||||
# Filter to Wandsworth (212) and Merton (315)
|
|
||||||
# Handle both string and integer columns
|
# 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')
|
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['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)
|
# Filter to schools only (RECTYPE == 1 means school level data)
|
||||||
if 'RECTYPE' in df.columns:
|
if 'RECTYPE' in df.columns:
|
||||||
df = df[df['RECTYPE'] == 1]
|
df = df[df['RECTYPE'] == 1]
|
||||||
|
|
||||||
# Add year and local authority name
|
# Add year and local authority name from LANAME column
|
||||||
df['year'] = year
|
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
|
# Standardize column names for our API
|
||||||
df = df.rename(columns={
|
df = df.rename(columns={
|
||||||
@@ -380,7 +376,7 @@ async def get_filter_options():
|
|||||||
|
|
||||||
if df.empty:
|
if df.empty:
|
||||||
return {
|
return {
|
||||||
"local_authorities": ["Wandsworth", "Merton"],
|
"local_authorities": [],
|
||||||
"school_types": [],
|
"school_types": [],
|
||||||
"years": [],
|
"years": [],
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -78,6 +78,14 @@ async function loadFilters() {
|
|||||||
const data = await fetchAPI('/api/filters');
|
const data = await fetchAPI('/api/filters');
|
||||||
if (!data) return;
|
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
|
// Populate school type filter
|
||||||
data.school_types.forEach(type => {
|
data.school_types.forEach(type => {
|
||||||
const option = document.createElement('option');
|
const option = document.createElement('option');
|
||||||
|
|||||||
@@ -41,7 +41,7 @@
|
|||||||
<section id="dashboard-view" class="view active">
|
<section id="dashboard-view" class="view active">
|
||||||
<div class="hero">
|
<div class="hero">
|
||||||
<h1 class="hero-title">Compare Primary School Performance</h1>
|
<h1 class="hero-title">Compare Primary School Performance</h1>
|
||||||
<p class="hero-subtitle">Explore and compare KS2 results across Wandsworth & Merton primary schools</p>
|
<p class="hero-subtitle">Explore and compare KS2 results across England's primary schools</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="search-section">
|
<div class="search-section">
|
||||||
@@ -57,8 +57,6 @@
|
|||||||
<div class="filter-row">
|
<div class="filter-row">
|
||||||
<select id="local-authority-filter" class="filter-select">
|
<select id="local-authority-filter" class="filter-select">
|
||||||
<option value="">All Areas</option>
|
<option value="">All Areas</option>
|
||||||
<option value="Wandsworth">Wandsworth</option>
|
|
||||||
<option value="Merton">Merton</option>
|
|
||||||
</select>
|
</select>
|
||||||
<select id="type-filter" class="filter-select">
|
<select id="type-filter" class="filter-select">
|
||||||
<option value="">All School Types</option>
|
<option value="">All School Types</option>
|
||||||
@@ -252,7 +250,7 @@
|
|||||||
|
|
||||||
<footer class="footer">
|
<footer class="footer">
|
||||||
<p>Data source: <a href="https://www.compare-school-performance.service.gov.uk/download-data" target="_blank">UK Government - Compare School Performance</a></p>
|
<p>Data source: <a href="https://www.compare-school-performance.service.gov.uk/download-data" target="_blank">UK Government - Compare School Performance</a></p>
|
||||||
<p class="footer-note">Primary school (KS2) data for Wandsworth and Merton. Data from 2019-2020, 2020-2021, 2021-2022 unavailable due to COVID-19 disruption.</p>
|
<p class="footer-note">Primary school (KS2) data for England. Data from 2019-2020, 2020-2021, 2021-2022 unavailable due to COVID-19 disruption.</p>
|
||||||
</footer>
|
</footer>
|
||||||
|
|
||||||
<script src="/static/app.js"></script>
|
<script src="/static/app.js"></script>
|
||||||
|
|||||||
Reference in New Issue
Block a user