feat(places): name every authority a place sits in #121
No files matched your search
@@ -1232,6 +1232,13 @@ async def get_place(request: Request, kind: str, slug: str,
|
|||||||
"place": {"kind": place.kind, "slug": place.slug, "name": place.name,
|
"place": {"kind": place.kind, "slug": place.slug, "name": place.name,
|
||||||
"count": len(place.urns),
|
"count": len(place.urns),
|
||||||
"parent_authority": place.parent_authority,
|
"parent_authority": place.parent_authority,
|
||||||
|
# Every authority the place meaningfully sits in. SW19 is
|
||||||
|
# mostly Merton but partly Wandsworth; naming one asserts
|
||||||
|
# something false.
|
||||||
|
"authorities": [
|
||||||
|
{"name": name, "slug": _slugify(name), "count": n}
|
||||||
|
for name, n in place.authorities
|
||||||
|
],
|
||||||
# Only phases that clear the threshold, so the page links
|
# Only phases that clear the threshold, so the page links
|
||||||
# variants that exist rather than 404s.
|
# variants that exist rather than 404s.
|
||||||
"phases": [ph for ph in ("primary", "secondary")
|
"phases": [ph for ph in ("primary", "secondary")
|
||||||
|
|||||||
+89
-18
@@ -30,6 +30,12 @@ class Place:
|
|||||||
name: str
|
name: str
|
||||||
urns: tuple[int, ...]
|
urns: tuple[int, ...]
|
||||||
parent_authority: str | None # authority NAME, for the 301 target
|
parent_authority: str | None # authority NAME, for the 301 target
|
||||||
|
# Every authority the place meaningfully sits in, largest first. A quarter
|
||||||
|
# of outcodes and a third of towns straddle a boundary — SW19 is mostly
|
||||||
|
# Merton but partly Wandsworth — so naming only one asserts something
|
||||||
|
# false. parent_authority stays single because a redirect needs one
|
||||||
|
# target; this is what the page shows.
|
||||||
|
authorities: tuple[tuple[str, int], ...] = ()
|
||||||
# URNs per phase, so the per-phase threshold can be applied without
|
# URNs per phase, so the per-phase threshold can be applied without
|
||||||
# re-querying. A place with 30 primaries and 2 secondaries publishes a
|
# re-querying. A place with 30 primaries and 2 secondaries publishes a
|
||||||
# primary variant and no secondary one.
|
# primary variant and no secondary one.
|
||||||
@@ -71,39 +77,100 @@ def _phase_urns(group, publishable: set[int]) -> dict[str, tuple[int, ...]]:
|
|||||||
return out
|
return out
|
||||||
|
|
||||||
|
|
||||||
def _parent_authority(group) -> str | None:
|
# A place is described by an authority when it holds at least a tenth of the
|
||||||
"""The most common authority in a group — the useful 301 target.
|
# schools, and at least two. GIAS carries occasional postcode errors — EN6
|
||||||
|
# lists two Shropshire schools among fourteen in Hertfordshire — and a bare
|
||||||
|
# "any authority present" rule would print those as though they were real.
|
||||||
|
# There is deliberately no cap on how many are named. An earlier cut stopped
|
||||||
|
# at three, which silently dropped the fourth in exactly the case where the
|
||||||
|
# information matters most — a genuinely fragmented place. The share rule is
|
||||||
|
# the only limit, and it already bounds the list at ten.
|
||||||
|
_AUTHORITY_MIN_SHARE = 0.10
|
||||||
|
_AUTHORITY_MIN_SCHOOLS = 2
|
||||||
|
|
||||||
|
|
||||||
|
def _authorities(group) -> tuple[tuple[str, int], ...]:
|
||||||
|
"""Authorities this place meaningfully sits in, largest first."""
|
||||||
|
from backend.app import EXCLUDED_FILTER_VALUES
|
||||||
|
|
||||||
A town spanning several authorities has no single parent, so the mode is
|
|
||||||
the honest answer rather than an arbitrary first row.
|
|
||||||
"""
|
|
||||||
if "local_authority" not in group.columns:
|
if "local_authority" not in group.columns:
|
||||||
return None
|
return ()
|
||||||
top = group["local_authority"].dropna()
|
counts = group["local_authority"].dropna().value_counts()
|
||||||
return str(top.mode().iloc[0]) if not top.empty else None
|
total = int(counts.sum())
|
||||||
|
if not total:
|
||||||
|
return ()
|
||||||
|
|
||||||
|
kept = [
|
||||||
|
(str(name), int(n)) for name, n in counts.items()
|
||||||
|
if str(name) not in EXCLUDED_FILTER_VALUES
|
||||||
|
and n >= _AUTHORITY_MIN_SCHOOLS
|
||||||
|
and n / total >= _AUTHORITY_MIN_SHARE
|
||||||
|
]
|
||||||
|
# A place too small or too fragmented for the share rule still names its
|
||||||
|
# largest authority, or the page would say nothing about where it is.
|
||||||
|
if not kept:
|
||||||
|
for name, n in counts.items():
|
||||||
|
if str(name) not in EXCLUDED_FILTER_VALUES:
|
||||||
|
return ((str(name), int(n)),)
|
||||||
|
return ()
|
||||||
|
return tuple(kept)
|
||||||
|
|
||||||
|
|
||||||
|
def _parent_authority(authorities: tuple[tuple[str, int], ...]) -> str | None:
|
||||||
|
"""The 301 target: the largest authority a place sits in.
|
||||||
|
|
||||||
|
Derived from `authorities` rather than computed separately. The first cut
|
||||||
|
used `mode()` here while `authorities` used `value_counts()`, and on an
|
||||||
|
exact tie pandas does not guarantee the two pick the same name — so the
|
||||||
|
redirect could have pointed somewhere other than the authority the page
|
||||||
|
named first. One computation, one answer.
|
||||||
|
|
||||||
|
Deriving it also inherits the sentinel filter, so a place can no longer
|
||||||
|
redirect to /schools/authority/does-not-apply.
|
||||||
|
"""
|
||||||
|
return authorities[0][0] if authorities else None
|
||||||
|
|
||||||
|
|
||||||
def _group(df, column: str, kind: str, publishable: set[int]) -> dict[str, Place]:
|
def _group(df, column: str, kind: str, publishable: set[int]) -> dict[str, Place]:
|
||||||
"""One Place per distinct value of `column` that clears the threshold."""
|
"""One Place per distinct SLUG in `column` that clears the threshold.
|
||||||
|
|
||||||
|
Grouped by slug, not by raw value, because GIAS spells the same place
|
||||||
|
several ways and they all resolve to one URL. Five town slugs come from
|
||||||
|
more than one spelling: "London" (1,819 schools) and "LONDON" (12) both
|
||||||
|
slugify to `london`; Weston-super-Mare is split 14/19 across two
|
||||||
|
spellings; Newcastle-under-Lyme across three.
|
||||||
|
|
||||||
|
Grouping by raw value meant the later group simply overwrote the earlier
|
||||||
|
one in this dict — so /schools/london could have shown twelve schools
|
||||||
|
instead of 1,819, silently and depending on row order.
|
||||||
|
|
||||||
|
The display name is the most common spelling, which is the one a reader
|
||||||
|
expects to see.
|
||||||
|
"""
|
||||||
from backend.app import _slugify
|
from backend.app import _slugify
|
||||||
|
|
||||||
if column not in df.columns:
|
if column not in df.columns:
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
|
working = df.assign(_slug=df[column].map(
|
||||||
|
lambda v: _slugify(str(v).strip()) if isinstance(v, str) and v.strip() else None))
|
||||||
|
working = working[working["_slug"].notna() & (working["_slug"] != "")]
|
||||||
|
|
||||||
out: dict[str, Place] = {}
|
out: dict[str, Place] = {}
|
||||||
for name, group in df.groupby(column, dropna=True):
|
for slug, group in working.groupby("_slug"):
|
||||||
name = str(name).strip()
|
slug = str(slug)
|
||||||
if not name:
|
|
||||||
continue
|
|
||||||
urns = tuple(sorted({int(u) for u in group["urn"]} & publishable))
|
urns = tuple(sorted({int(u) for u in group["urn"]} & publishable))
|
||||||
if len(urns) < MIN_SCHOOLS:
|
if len(urns) < MIN_SCHOOLS:
|
||||||
continue
|
continue
|
||||||
slug = _slugify(name)
|
spellings = group[column].dropna().value_counts()
|
||||||
if not slug:
|
if spellings.empty:
|
||||||
continue
|
continue
|
||||||
|
name = str(spellings.index[0]).strip()
|
||||||
|
authorities = () if kind == "authority" else _authorities(group)
|
||||||
place = Place(
|
place = Place(
|
||||||
kind=kind, slug=slug, name=name, urns=urns,
|
kind=kind, slug=slug, name=name, urns=urns,
|
||||||
parent_authority=_parent_authority(group) if kind == "town" else None,
|
parent_authority=_parent_authority(authorities),
|
||||||
|
authorities=authorities,
|
||||||
phase_urns=_phase_urns(group, publishable),
|
phase_urns=_phase_urns(group, publishable),
|
||||||
)
|
)
|
||||||
out[place.key] = place
|
out[place.key] = place
|
||||||
@@ -136,8 +203,10 @@ def _outcode_places(df, publishable: set[int]) -> dict[str, Place]:
|
|||||||
urns = tuple(sorted({int(u) for u in group["urn"]} & publishable))
|
urns = tuple(sorted({int(u) for u in group["urn"]} & publishable))
|
||||||
if len(urns) < MIN_SCHOOLS:
|
if len(urns) < MIN_SCHOOLS:
|
||||||
continue
|
continue
|
||||||
|
authorities = _authorities(group)
|
||||||
place = Place(kind="outcode", slug=str(oc).lower(), name=str(oc),
|
place = Place(kind="outcode", slug=str(oc).lower(), name=str(oc),
|
||||||
urns=urns, parent_authority=_parent_authority(group),
|
urns=urns, parent_authority=_parent_authority(authorities),
|
||||||
|
authorities=authorities,
|
||||||
phase_urns=_phase_urns(group, publishable))
|
phase_urns=_phase_urns(group, publishable))
|
||||||
out[place.key] = place
|
out[place.key] = place
|
||||||
return out
|
return out
|
||||||
@@ -179,8 +248,10 @@ def _locality_places(df, publishable: set[int],
|
|||||||
"threshold of %d - not published",
|
"threshold of %d - not published",
|
||||||
slug, ", ".join(outcodes), len(urns), MIN_SCHOOLS)
|
slug, ", ".join(outcodes), len(urns), MIN_SCHOOLS)
|
||||||
continue
|
continue
|
||||||
|
authorities = _authorities(group)
|
||||||
place = Place(kind="locality", slug=slug, name=name, urns=urns,
|
place = Place(kind="locality", slug=slug, name=name, urns=urns,
|
||||||
parent_authority=_parent_authority(group),
|
parent_authority=_parent_authority(authorities),
|
||||||
|
authorities=authorities,
|
||||||
phase_urns=_phase_urns(group, publishable))
|
phase_urns=_phase_urns(group, publishable))
|
||||||
out[place.key] = place
|
out[place.key] = place
|
||||||
return out
|
return out
|
||||||
|
|||||||
@@ -229,3 +229,117 @@ def test_no_curated_locality_names_a_london_borough():
|
|||||||
f"these are boroughs, not districts: {sorted(named)} - they already "
|
f"these are boroughs, not districts: {sorted(named)} - they already "
|
||||||
"have an authority page covering every school"
|
"have an authority page covering every school"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def test_a_place_names_every_authority_it_straddles():
|
||||||
|
"""SW19 is mostly Merton but partly Wandsworth.
|
||||||
|
|
||||||
|
A quarter of viable outcodes and a third of viable towns cross an
|
||||||
|
authority boundary, so naming only the largest asserts something false.
|
||||||
|
"""
|
||||||
|
rows = (_town(26, "London", "Merton", start=300000)
|
||||||
|
+ _town(7, "London", "Wandsworth", start=400000))
|
||||||
|
for r in rows:
|
||||||
|
r["postcode"] = "SW19 1AA"
|
||||||
|
reg = build_place_registry(_df(rows))
|
||||||
|
|
||||||
|
names = [n for n, _ in reg["outcode:sw19"].authorities]
|
||||||
|
assert names == ["Merton", "Wandsworth"] # largest first
|
||||||
|
assert dict(reg["outcode:sw19"].authorities)["Wandsworth"] == 7
|
||||||
|
|
||||||
|
|
||||||
|
def test_the_redirect_target_stays_a_single_authority():
|
||||||
|
# parent_authority and authorities do different jobs: a 301 needs one
|
||||||
|
# target, the page needs the truth.
|
||||||
|
rows = (_town(26, "London", "Merton", start=300000)
|
||||||
|
+ _town(7, "London", "Wandsworth", start=400000))
|
||||||
|
for r in rows:
|
||||||
|
r["postcode"] = "SW19 1AA"
|
||||||
|
reg = build_place_registry(_df(rows))
|
||||||
|
assert reg["outcode:sw19"].parent_authority == "Merton"
|
||||||
|
|
||||||
|
|
||||||
|
def test_a_stray_authority_below_the_share_threshold_is_not_named():
|
||||||
|
# GIAS carries postcode errors — EN6 lists two Shropshire schools among
|
||||||
|
# fourteen in Hertfordshire. Printing those as though real would be worse
|
||||||
|
# than omitting them.
|
||||||
|
rows = (_town(30, "Barnet", "Hertfordshire", start=300000)
|
||||||
|
+ _town(1, "Barnet", "Shropshire", start=400000))
|
||||||
|
for r in rows:
|
||||||
|
r["postcode"] = "EN6 1AA"
|
||||||
|
reg = build_place_registry(_df(rows))
|
||||||
|
assert [n for n, _ in reg["outcode:en6"].authorities] == ["Hertfordshire"]
|
||||||
|
|
||||||
|
|
||||||
|
def test_a_sentinel_authority_is_never_named():
|
||||||
|
rows = (_town(20, "London", "Merton", start=300000)
|
||||||
|
+ _town(6, "London", "Does not apply", start=400000))
|
||||||
|
for r in rows:
|
||||||
|
r["postcode"] = "SW19 1AA"
|
||||||
|
reg = build_place_registry(_df(rows))
|
||||||
|
assert [n for n, _ in reg["outcode:sw19"].authorities] == ["Merton"]
|
||||||
|
|
||||||
|
|
||||||
|
def test_a_place_always_names_at_least_one_authority():
|
||||||
|
# Even when every authority is below the share threshold, the page has to
|
||||||
|
# say where the place is.
|
||||||
|
rows = []
|
||||||
|
for i, la in enumerate(["A", "B", "C", "D", "E", "F", "G"]):
|
||||||
|
rows += _town(1, "Fragmented", la, start=300000 + i * 100)
|
||||||
|
reg = build_place_registry(_df(rows))
|
||||||
|
place = reg.get("town:fragmented")
|
||||||
|
assert place is not None
|
||||||
|
assert len(place.authorities) == 1
|
||||||
|
|
||||||
|
|
||||||
|
def test_every_qualifying_authority_is_named_with_no_cap():
|
||||||
|
"""An earlier cut stopped at three, dropping the fourth silently.
|
||||||
|
|
||||||
|
That truncation bit exactly where the information matters most — a
|
||||||
|
genuinely fragmented place — and nothing recorded it.
|
||||||
|
"""
|
||||||
|
rows = []
|
||||||
|
for i, la in enumerate(["Hackney", "Lambeth", "Westminster", "Lewisham"]):
|
||||||
|
rows += _town(3, "Fourway", la, start=300000 + i * 100)
|
||||||
|
reg = build_place_registry(_df(rows))
|
||||||
|
assert len(reg["town:fourway"].authorities) == 4
|
||||||
|
|
||||||
|
|
||||||
|
def test_the_redirect_target_is_the_authority_named_first():
|
||||||
|
"""They were computed separately — mode() against value_counts() — and on
|
||||||
|
an exact tie pandas does not guarantee the two agree."""
|
||||||
|
rows = (_town(26, "London", "Merton", start=300000)
|
||||||
|
+ _town(7, "London", "Wandsworth", start=400000))
|
||||||
|
for r in rows:
|
||||||
|
r["postcode"] = "SW19 1AA"
|
||||||
|
place = build_place_registry(_df(rows))["outcode:sw19"]
|
||||||
|
assert place.parent_authority == place.authorities[0][0]
|
||||||
|
|
||||||
|
|
||||||
|
def test_a_place_never_redirects_to_a_sentinel_authority():
|
||||||
|
# Deriving the parent from `authorities` inherits its sentinel filter.
|
||||||
|
rows = (_town(6, "Someplace", "Does not apply", start=300000)
|
||||||
|
+ _town(5, "Someplace", "Essex", start=400000))
|
||||||
|
reg = build_place_registry(_df(rows))
|
||||||
|
assert reg["town:someplace"].parent_authority == "Essex"
|
||||||
|
|
||||||
|
|
||||||
|
def test_spellings_of_one_place_are_merged_not_overwritten():
|
||||||
|
"""GIAS spells the same place several ways, and they share a URL.
|
||||||
|
|
||||||
|
"London" (1,819 schools) and "LONDON" (12) both slugify to `london`.
|
||||||
|
Grouping by raw value let the later group overwrite the earlier one, so
|
||||||
|
the page could have shown twelve schools instead of 1,819 — silently, and
|
||||||
|
depending on row order.
|
||||||
|
"""
|
||||||
|
rows = (_town(6, "Weston-super-Mare", "North Somerset", start=300000)
|
||||||
|
+ _town(5, "Weston-Super-Mare", "North Somerset", start=400000))
|
||||||
|
reg = build_place_registry(_df(rows))
|
||||||
|
assert len(reg["town:weston-super-mare"].urns) == 11
|
||||||
|
|
||||||
|
|
||||||
|
def test_the_merged_place_takes_its_most_common_spelling():
|
||||||
|
rows = (_town(9, "Newcastle-under-Lyme", "Staffordshire", start=300000)
|
||||||
|
+ _town(5, "NEWCASTLE-UNDER-LYME", "Staffordshire", start=400000))
|
||||||
|
reg = build_place_registry(_df(rows))
|
||||||
|
assert reg["town:newcastle-under-lyme"].name == "Newcastle-under-Lyme"
|
||||||
@@ -1885,3 +1885,29 @@ test('no page title repeats the brand', async ({ page }) => {
|
|||||||
expect(brands, `${path} repeats the brand: ${title}`).toBeLessThanOrEqual(1);
|
expect(brands, `${path} repeats the brand: ${title}`).toBeLessThanOrEqual(1);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('a place straddling a boundary names every authority it sits in', async ({ page }) => {
|
||||||
|
// A quarter of outcodes and a third of towns cross an authority boundary —
|
||||||
|
// SW19 is mostly Merton but partly Wandsworth. Naming only the largest
|
||||||
|
// asserts something false about the place.
|
||||||
|
const { places } = await (await page.request.get('/api/places')).json();
|
||||||
|
const outcode = places.find((p: { kind: string }) => p.kind === 'outcode');
|
||||||
|
expect(outcode).toBeTruthy();
|
||||||
|
|
||||||
|
// Find any place the registry reports as straddling.
|
||||||
|
let straddling: { kind: string; slug: string } | null = null;
|
||||||
|
for (const p of places.filter((p: { kind: string }) => p.kind === 'outcode').slice(0, 40)) {
|
||||||
|
const d = await (await page.request.get(`/api/places/outcode/${p.slug}`)).json();
|
||||||
|
if ((d.place.authorities ?? []).length > 1) { straddling = p; break; }
|
||||||
|
}
|
||||||
|
test.skip(!straddling, 'no straddling outcode found in the sample');
|
||||||
|
|
||||||
|
const detail = await (await page.request.get(
|
||||||
|
`/api/places/outcode/${straddling!.slug}`)).json();
|
||||||
|
await page.goto(`/schools/near/${straddling!.slug}`);
|
||||||
|
|
||||||
|
for (const a of detail.place.authorities) {
|
||||||
|
await expect(page.locator(`a[href="/schools/authority/${a.slug}"]`).first())
|
||||||
|
.toBeVisible();
|
||||||
|
}
|
||||||
|
});
|
||||||
@@ -199,3 +199,47 @@ describe('PlaceView table alignment', () => {
|
|||||||
expect(container.querySelectorAll('th')[0].className).toBe('');
|
expect(container.querySelectorAll('th')[0].className).toBe('');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('PlaceView authorities', () => {
|
||||||
|
const straddling: PlaceDetail = {
|
||||||
|
place: { kind: 'outcode', slug: 'sw19', name: 'SW19', count: 33,
|
||||||
|
parent_authority: 'Merton', phases: ['primary'],
|
||||||
|
authorities: [
|
||||||
|
{ name: 'Merton', slug: 'merton', count: 26 },
|
||||||
|
{ name: 'Wandsworth', slug: 'wandsworth', count: 7 },
|
||||||
|
] },
|
||||||
|
schools: [
|
||||||
|
{ urn: 1, school_name: 'Alpha Primary', phase: 'Primary',
|
||||||
|
rwm_expected_pct: 82, attainment_8_score: null } as never,
|
||||||
|
],
|
||||||
|
averages: { rwm_expected_pct: 63, attainment_8_score: null },
|
||||||
|
};
|
||||||
|
|
||||||
|
it('names every authority the place straddles, not just the largest', () => {
|
||||||
|
// SW19 is mostly Merton but partly Wandsworth. Naming one asserts
|
||||||
|
// something false about a quarter of outcodes.
|
||||||
|
render(<PlaceView detail={straddling} englandAverage={61} neighbours={[]} />);
|
||||||
|
expect(screen.getByRole('link', { name: 'Merton' }))
|
||||||
|
.toHaveAttribute('href', '/schools/authority/merton');
|
||||||
|
expect(screen.getByRole('link', { name: 'Wandsworth' }))
|
||||||
|
.toHaveAttribute('href', '/schools/authority/wandsworth');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('joins them readably rather than as a bare list', () => {
|
||||||
|
// Asserted on the summary line's whole text: a loose /and/ matcher also
|
||||||
|
// hits "Wandsworth".
|
||||||
|
const { container } = render(<PlaceView detail={straddling}
|
||||||
|
englandAverage={61} neighbours={[]} />);
|
||||||
|
const summary = container.querySelector('header p');
|
||||||
|
expect(summary?.textContent).toContain('Merton and Wandsworth');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('falls back to the single parent when the field is absent', () => {
|
||||||
|
// A cached API response predating the authorities field must not blank
|
||||||
|
// the line entirely.
|
||||||
|
const legacy = { ...straddling,
|
||||||
|
place: { ...straddling.place, authorities: undefined } };
|
||||||
|
render(<PlaceView detail={legacy} englandAverage={61} neighbours={[]} />);
|
||||||
|
expect(screen.getByRole('link', { name: 'Merton' })).toBeInTheDocument();
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -106,6 +106,13 @@ function SchoolTable({ schools, phase }: { schools: School[]; phase: PhaseKey })
|
|||||||
|
|
||||||
export function PlaceView({ detail, phase, englandAverage, neighbours }: Props) {
|
export function PlaceView({ detail, phase, englandAverage, neighbours }: Props) {
|
||||||
const { place, schools, averages } = detail;
|
const { place, schools, averages } = detail;
|
||||||
|
// Fall back to the single parent when the API predates the authorities
|
||||||
|
// field, so a stale cache never blanks the line entirely.
|
||||||
|
const authorities = place.authorities?.length
|
||||||
|
? place.authorities
|
||||||
|
: place.parent_authority
|
||||||
|
? [{ name: place.parent_authority, slug: authoritySlug(place.parent_authority), count: 0 }]
|
||||||
|
: [];
|
||||||
const local = averages[METRICS[phase ?? 'primary'].key];
|
const local = averages[METRICS[phase ?? 'primary'].key];
|
||||||
const phaseWord = phase === 'secondary' ? 'Secondary schools'
|
const phaseWord = phase === 'secondary' ? 'Secondary schools'
|
||||||
: phase === 'primary' ? 'Primary schools' : 'Schools';
|
: phase === 'primary' ? 'Primary schools' : 'Schools';
|
||||||
@@ -163,13 +170,20 @@ export function PlaceView({ detail, phase, englandAverage, neighbours }: Props)
|
|||||||
<h1>{phaseWord} in {place.name}</h1>
|
<h1>{phaseWord} in {place.name}</h1>
|
||||||
<p className={styles.summary}>
|
<p className={styles.summary}>
|
||||||
{place.count} schools
|
{place.count} schools
|
||||||
{place.parent_authority && (
|
{authorities.length > 0 && (
|
||||||
<>
|
<>
|
||||||
{' · '}
|
{' · '}
|
||||||
<Link href={`/schools/authority/${authoritySlug(place.parent_authority)}`}
|
{/* Every authority, not just the largest. A quarter of outcodes
|
||||||
className={styles.inlineLink}>
|
and a third of towns cross a boundary: SW19 is mostly Merton
|
||||||
{place.parent_authority}
|
but partly Wandsworth, and naming one asserts otherwise. */}
|
||||||
</Link>
|
{authorities.map((a, i) => (
|
||||||
|
<span key={a.slug}>
|
||||||
|
{i > 0 && (i === authorities.length - 1 ? ' and ' : ', ')}
|
||||||
|
<Link href={`/schools/authority/${a.slug}`} className={styles.inlineLink}>
|
||||||
|
{a.name}
|
||||||
|
</Link>
|
||||||
|
</span>
|
||||||
|
))}
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</p>
|
</p>
|
||||||
|
|||||||
@@ -18,8 +18,19 @@ export interface PlaceSummary {
|
|||||||
phases?: string[];
|
phases?: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface PlaceAuthority {
|
||||||
|
name: string;
|
||||||
|
slug: string;
|
||||||
|
count: number;
|
||||||
|
}
|
||||||
|
|
||||||
export interface PlaceDetail {
|
export interface PlaceDetail {
|
||||||
place: PlaceSummary & { parent_authority: string | null };
|
place: PlaceSummary & {
|
||||||
|
parent_authority: string | null;
|
||||||
|
/** Every authority the place meaningfully sits in, largest first. SW19 is
|
||||||
|
* mostly Merton but partly Wandsworth. */
|
||||||
|
authorities?: PlaceAuthority[];
|
||||||
|
};
|
||||||
schools: School[];
|
schools: School[];
|
||||||
averages: {
|
averages: {
|
||||||
rwm_expected_pct: number | null;
|
rwm_expected_pct: number | null;
|
||||||
|
|||||||
Reference in new issue
Block a user