feat(data): publish England only, dropping Welsh and overseas establishments
GIAS ships the whole UK plus overseas and offshore establishments. None of
them carry comparable DfE performance data — Wales does not publish on the
English measures at all — so every one of these pages rendered with null
results, null Ofsted and null phase. There were 2,036 of them: 1,569 Welsh,
123 offshore (Jersey, Guernsey, Isle of Man, Gibraltar), 316 British schools
overseas and 28 service children's schools. All 2,036 were being submitted to
search engines, alongside 29 local authorities that existed in the filters
purely to list them.
Filter at the mart boundary rather than the view layer. dim_school and
dim_location both exclude TypeOfEstablishment in {25, 26, 30, 37}, listed once
as vars.non_england_school_type_codes. Everything downstream reads those two
marts — search, the school page, /api/filters, rankings, Typesense and
build_sitemap() — so one filter removes them from the site and the sitemap
together, and Typesense drops them on its next rebuild since it recreates the
collection and swaps the alias rather than upserting in place.
coalesce rather than a bare NOT IN: a null type code would make the predicate
null and drop the row silently, and an unknown type is not grounds for
exclusion. No establishment has a null type today, but a future GIAS refresh
could ship one and the loss would be invisible.
assert_england_only_schools guards both directions: no excluded type survives
in dim_school, and dim_location holds no URN dim_school lacks — the API
inner-joins them, so the two filters drifting apart would silently shrink the
corpus.
Corpus goes from 27,229 schools to 25,193, and the authority list from 182 to
153. The 1,569 Welsh URLs now 404.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015mWQnpye9F299NVRCCSRvj
This commit is contained in:
1 parent
228eb214f5
commit
7650b16f62
6 files changed
+461
-1
No files matched your search
@@ -1449,3 +1449,104 @@ test('no single section dominates the height of a school page', async ({ page })
|
||||
+ sections.map((s) => `${s.id}=${s.h}`).join(', '),
|
||||
).toBeLessThan(2.5);
|
||||
});
|
||||
|
||||
/*
|
||||
* England-only corpus.
|
||||
*
|
||||
* GIAS ships the whole UK plus overseas and offshore establishments, none of
|
||||
* which carry comparable DfE performance data. dim_school and dim_location
|
||||
* exclude them (vars.non_england_school_type_codes in dbt_project.yml), which
|
||||
* keeps them out of the site, the filter lists and the sitemap together.
|
||||
*
|
||||
* These assert the published surface, not the warehouse: the dbt test
|
||||
* assert_england_only_schools guards the marts, and these guard what the
|
||||
* environment actually serves once the marts have been rebuilt.
|
||||
*/
|
||||
|
||||
const WELSH_AUTHORITIES = [
|
||||
'Blaenau Gwent', 'Bridgend', 'Caerphilly', 'Cardiff', 'Carmarthenshire',
|
||||
'Ceredigion', 'Conwy', 'Denbighshire', 'Flintshire', 'Gwynedd',
|
||||
'Isle of Anglesey', 'Merthyr Tydfil', 'Monmouthshire', 'Neath Port Talbot',
|
||||
'Newport', 'Pembrokeshire', 'Powys', 'Rhondda Cynon Taf', 'Swansea',
|
||||
'Torfaen', 'Vale of Glamorgan', 'Wrexham',
|
||||
];
|
||||
|
||||
const NON_ENGLAND_AUTHORITIES = [
|
||||
'BFPO Overseas Establishments', 'Fieldwork Overseas Establishments',
|
||||
'Gibraltar Overseas Establishments', 'Guernsey Offshore Establishments',
|
||||
'Isle of Man Offshore Establishments', 'Jersey Offshore Establishments',
|
||||
'Scotland Offshore Establishments',
|
||||
];
|
||||
|
||||
const NON_ENGLAND_TYPES = [
|
||||
'Welsh establishment', 'Offshore schools',
|
||||
"Service children's education", 'British schools overseas',
|
||||
];
|
||||
|
||||
test('the local authority filter offers no Welsh or overseas authority', async ({ page }) => {
|
||||
const res = await page.request.get('/api/filters');
|
||||
expect(res.ok()).toBeTruthy();
|
||||
const { local_authorities: las } = await res.json();
|
||||
|
||||
expect(Array.isArray(las)).toBeTruthy();
|
||||
// Guards against the list being empty, which would pass the check below
|
||||
// for the wrong reason.
|
||||
expect(las.length).toBeGreaterThan(100);
|
||||
|
||||
const leaked = [...WELSH_AUTHORITIES, ...NON_ENGLAND_AUTHORITIES]
|
||||
.filter((la) => las.includes(la));
|
||||
expect(leaked, `non-England authorities still offered: ${leaked.join(', ')}`)
|
||||
.toEqual([]);
|
||||
});
|
||||
|
||||
test('the school type filter offers no non-England establishment type', async ({ page }) => {
|
||||
const res = await page.request.get('/api/filters');
|
||||
expect(res.ok()).toBeTruthy();
|
||||
const { school_types: types } = await res.json();
|
||||
|
||||
expect(Array.isArray(types)).toBeTruthy();
|
||||
expect(types.length).toBeGreaterThan(10);
|
||||
|
||||
const leaked = NON_ENGLAND_TYPES.filter((t) => types.includes(t));
|
||||
expect(leaked, `non-England types still offered: ${leaked.join(', ')}`)
|
||||
.toEqual([]);
|
||||
});
|
||||
|
||||
test('searching a Welsh authority by name returns no schools', async ({ page }) => {
|
||||
// Cardiff held 144 Welsh establishments and nothing else, so the authority
|
||||
// should now be absent from the corpus entirely rather than merely thinned.
|
||||
const res = await page.request.get('/api/schools?local_authority=Cardiff&page_size=1');
|
||||
expect(res.ok()).toBeTruthy();
|
||||
const body = await res.json();
|
||||
expect(body.total ?? (body.schools ?? []).length).toBe(0);
|
||||
});
|
||||
|
||||
test('a Welsh school URL 404s while an English one still resolves', async ({ page }) => {
|
||||
// Paired on purpose: the Welsh assertion alone would also pass if the whole
|
||||
// site were down, which is the failure this test most needs to distinguish.
|
||||
const english = await page.request.get('/api/schools?search=primary&per_page=1');
|
||||
expect(english.ok()).toBeTruthy();
|
||||
const [first] = (await english.json()).schools ?? [];
|
||||
expect(first, 'no English school available to compare against').toBeTruthy();
|
||||
|
||||
const good = await page.goto(`/school/${first.urn}-x`);
|
||||
expect(good?.status(), 'an English school should still resolve').toBeLessThan(400);
|
||||
|
||||
// Adamsdown Primary School, Cardiff — a Welsh establishment (URN 401559).
|
||||
const welsh = await page.goto('/school/401559-adamsdown-primary-school');
|
||||
expect(welsh?.status(), 'a Welsh school should no longer resolve').toBe(404);
|
||||
});
|
||||
|
||||
test('the sitemap submits no Welsh or overseas school', async ({ page }) => {
|
||||
const res = await page.request.get('/sitemap.xml');
|
||||
expect(res.ok()).toBeTruthy();
|
||||
const xml = await res.text();
|
||||
|
||||
const urlCount = (xml.match(/<url>/g) ?? []).length;
|
||||
expect(urlCount, 'sitemap looks empty or truncated').toBeGreaterThan(1000);
|
||||
|
||||
// 401559 (Cardiff) and 402426 (ACT Schools, Cardiff) were both submitted
|
||||
// before the England-only filter landed.
|
||||
expect(xml).not.toContain('/school/401559');
|
||||
expect(xml).not.toContain('/school/402426');
|
||||
});
|
||||
Reference in new issue
Block a user