feat(utils): add buildOfstedListBadge helper and fetchNationalAverages

- Add ofsted_framework field to School type
- Add OfstedListBadge interface and buildOfstedListBadge pure function to utils.ts
- Add fetchNationalAverages API function that calls GET /api/national-averages
- Add test suite for buildOfstedListBadge (all 6 new tests pass)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Tudor Sitaru
2026-04-13 13:52:05 +01:00
parent 6d02d366ce
commit 8a6758b591
4 changed files with 107 additions and 0 deletions
+21
View File
@@ -15,6 +15,7 @@ import type {
RankingsParams,
APIError,
LAaveragesResponse,
NationalAverages,
} from './types';
// ============================================================================
@@ -261,6 +262,26 @@ export async function fetchLAaverages(
return handleResponse<LAaveragesResponse>(response);
}
/**
* Fetch official DfE KS2 national averages (primary) and computed KS4 secondary averages.
* Returns latest year snapshot plus per-year history for chart reference lines.
*/
export async function fetchNationalAverages(
options: RequestInit = {}
): Promise<NationalAverages> {
const url = `${API_BASE_URL}/national-averages`;
const response = await fetch(url, {
...options,
next: {
revalidate: 3600,
...options.next,
},
});
return handleResponse<NationalAverages>(response);
}
/**
* Fetch database statistics and info
*/