refactor: rename similar → nearby, so the code says what the section does
The section ranks on distance and is headed "Other schools nearby", but every identifier still called it "similar" — the exact drift that leaves a later reader trusting a name over the behaviour. Mechanical: files, the module, the payload key, the type, the components, the prop. No behaviour change; the suites are unchanged in count and still green. Free to do now because #150 has not merged, so the payload key rename needs no lockstep deploy. Uses of "similar" that are ordinary English — progress measures compared to similar pupils, and unrelated comments — are untouched. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
5c0ccc693d
commit
cd6a45bf7d
15 files changed
+102
-102
No files matched your search
+6
-6
@@ -41,7 +41,7 @@ from .data_loader import get_data_info as get_db_info
|
||||
from . import flags
|
||||
from .places import build_place_index, build_place_registry, places_for_urn
|
||||
from .schemas import METRIC_DEFINITIONS, PHASE_GROUPS, RANKING_COLUMNS, SCHOOL_COLUMNS
|
||||
from .similar_schools import select_similar
|
||||
from .nearby_schools import select_nearby
|
||||
from .utils import clean_for_json, convert_to_native
|
||||
|
||||
# Values to exclude from filter dropdowns (empty strings, non-applicable labels)
|
||||
@@ -266,10 +266,10 @@ def _places_payload(urn: int) -> list[dict]:
|
||||
return payload
|
||||
|
||||
|
||||
def _similar_schools_payload(urn: int) -> list[dict]:
|
||||
def _nearby_schools_payload(urn: int) -> list[dict]:
|
||||
"""The nearest eligible schools this page may offer, closest first.
|
||||
|
||||
Phase and reach are read from the school's own row inside select_similar,
|
||||
Phase and reach are read from the school's own row inside select_nearby,
|
||||
so nothing here can hand it a phase that disagrees with the data.
|
||||
|
||||
Wrapped: a failure in selection must never 500 a page that is otherwise
|
||||
@@ -277,12 +277,12 @@ def _similar_schools_payload(urn: int) -> list[dict]:
|
||||
section simply does not render.
|
||||
"""
|
||||
try:
|
||||
return select_similar(load_latest_school_data(), int(urn))
|
||||
return select_nearby(load_latest_school_data(), int(urn))
|
||||
except Exception:
|
||||
import logging
|
||||
|
||||
logging.getLogger(__name__).exception(
|
||||
"Similar schools selection failed for urn=%s", urn
|
||||
"Nearby schools selection failed for urn=%s", urn
|
||||
)
|
||||
return []
|
||||
|
||||
@@ -1000,7 +1000,7 @@ async def get_school_details(request: Request, urn: int):
|
||||
# The nearest eligible schools, closest first. Always present on a
|
||||
# build with this code; the frontend treats absent and empty
|
||||
# identically, which is what lets the two images deploy independently.
|
||||
"similar_schools": _similar_schools_payload(urn),
|
||||
"nearby_schools": _nearby_schools_payload(urn),
|
||||
"yearly_data": clean_for_json(school_data),
|
||||
# Supplementary data (null if not yet populated by Kestra)
|
||||
"ofsted": supplementary.get("ofsted"),
|
||||
|
||||
Reference in new issue
Block a user