2026-02-02 20:34:35 +00:00
|
|
|
/**
|
|
|
|
|
* Rankings Page (SSR)
|
|
|
|
|
* Display top-ranked schools by various metrics
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import { fetchRankings, fetchFilters, fetchMetrics } from '@/lib/api';
|
|
|
|
|
import { RankingsView } from '@/components/RankingsView';
|
|
|
|
|
import type { Metadata } from 'next';
|
|
|
|
|
|
|
|
|
|
interface RankingsPageProps {
|
|
|
|
|
searchParams: Promise<{
|
|
|
|
|
metric?: string;
|
|
|
|
|
local_authority?: string;
|
|
|
|
|
year?: string;
|
|
|
|
|
}>;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const metadata: Metadata = {
|
|
|
|
|
title: 'School Rankings',
|
feat: add secondary school support with KS4 data and metric tooltips
- Backend: replace INNER JOIN ks2 with UNION ALL (ks2 + ks4) so primary
and secondary schools both appear in the main DataFrame
- Backend: add /api/national-averages endpoint computing means from live
data, replacing the hardcoded NATIONAL_AVG constant on the frontend
- Backend: add phase filter param to /api/schools; return phases from
/api/filters; fix hardcoded "phase": "Primary" in school detail endpoint
- Backend: add KS4 metric definitions (Attainment 8, Progress 8, EBacc,
English & Maths pass rates) to METRIC_DEFINITIONS and RANKING_COLUMNS
- Frontend: SchoolDetailView is now phase-aware — secondary schools show
a GCSE Results section (Att8, P8, E&M, EBacc) instead of SATs; phonics
tab hidden for secondary; admissions says Year 7 instead of Year 3;
history table shows KS4 columns; chart datasets switch for secondary
- Frontend: new MetricTooltip component (CSS-only ⓘ icon) backed by
METRIC_EXPLANATIONS — added to RWM, GPS, SEN, EAL, IDACI, progress
scores and all KS4 metrics throughout SchoolDetailView and SchoolCard
- Frontend: METRIC_EXPLANATIONS extended with KS4 terms (Attainment 8,
Progress 8, EBacc) and previously missing terms (SEN, EHCP, EAL, IDACI)
- Frontend: SchoolCard expands "RWM" to "Reading, Writing & Maths" and
shows Attainment 8 / English & Maths Grade 4+ for secondary schools
- Frontend: FilterBar adds Phase dropdown (Primary / Secondary / All-through)
- Frontend: HomeView hero copy updated; compact list shows phase-aware metric
- Global metadata updated to remove "primary only" framing
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-28 14:59:40 +00:00
|
|
|
description: 'Top-ranked schools by SATs and GCSE performance across England',
|
|
|
|
|
keywords: 'school rankings, top schools, best schools, KS2 rankings, KS4 rankings, school league tables',
|
2026-02-02 20:34:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Force dynamic rendering
|
|
|
|
|
export const dynamic = 'force-dynamic';
|
|
|
|
|
|
|
|
|
|
export default async function RankingsPage({ searchParams }: RankingsPageProps) {
|
|
|
|
|
const { metric: metricParam, local_authority, year: yearParam } = await searchParams;
|
|
|
|
|
|
|
|
|
|
const metric = metricParam || 'rwm_expected_pct';
|
|
|
|
|
const year = yearParam ? parseInt(yearParam) : undefined;
|
|
|
|
|
|
2026-02-02 21:28:50 +00:00
|
|
|
// Fetch rankings data with error handling
|
|
|
|
|
try {
|
|
|
|
|
const [rankingsResponse, filtersResponse, metricsResponse] = await Promise.all([
|
|
|
|
|
fetchRankings({
|
|
|
|
|
metric,
|
|
|
|
|
local_authority,
|
|
|
|
|
year,
|
|
|
|
|
limit: 100,
|
|
|
|
|
}),
|
|
|
|
|
fetchFilters(),
|
|
|
|
|
fetchMetrics(),
|
|
|
|
|
]);
|
|
|
|
|
|
2026-02-02 22:00:07 +00:00
|
|
|
// Metrics is already an array
|
|
|
|
|
const metricsArray = metricsResponse?.metrics || [];
|
2026-02-02 21:28:50 +00:00
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<RankingsView
|
|
|
|
|
rankings={rankingsResponse?.rankings || []}
|
2026-03-28 15:03:03 +00:00
|
|
|
filters={filtersResponse || { local_authorities: [], school_types: [], years: [], phases: [] }}
|
2026-02-02 21:28:50 +00:00
|
|
|
metrics={metricsArray}
|
|
|
|
|
selectedMetric={metric}
|
|
|
|
|
selectedArea={local_authority}
|
|
|
|
|
selectedYear={year}
|
|
|
|
|
/>
|
|
|
|
|
);
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('Error fetching data for rankings page:', error);
|
|
|
|
|
|
|
|
|
|
// Return error state with empty data
|
|
|
|
|
return (
|
|
|
|
|
<RankingsView
|
|
|
|
|
rankings={[]}
|
2026-03-28 15:03:03 +00:00
|
|
|
filters={{ local_authorities: [], school_types: [], years: [], phases: [] }}
|
2026-02-02 21:28:50 +00:00
|
|
|
metrics={[]}
|
|
|
|
|
selectedMetric={metric}
|
|
|
|
|
selectedArea={local_authority}
|
|
|
|
|
selectedYear={year}
|
|
|
|
|
/>
|
|
|
|
|
);
|
|
|
|
|
}
|
2026-02-02 20:34:35 +00:00
|
|
|
}
|