Conversation
There was a problem hiding this comment.
Pull request overview
Adds support for UK country boundaries (UKC24) across the backend area model, import tooling, frontend choropleth configuration, and backfills existing geocoded records with derived UKC24 codes.
Changes:
- Add
UKC24to area set / group enums and labels, plus size ordering. - Add a new
importCountriesCLI command and Mapbox choropleth layer config for countries. - Add a migration to populate
geocode_result.areas.UKC24based on existingUKR18codes.
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/server/models/AreaSet.ts | Adds UKC24 to area set + group enums and size ranking. |
| src/server/commands/importCountries.ts | New importer to load countries GeoJSON into the area table under UKC24. |
| src/labels.ts | Adds UKC24 labels; updates group labels for multi-zoom groups. |
| src/app/map/[id]/components/Choropleth/configs.ts | Adds Mapbox choropleth config for UK country boundaries (UKC24). |
| src/app/map/[id]/components/Choropleth/areas.ts | Adjusts valid boundary group selection logic when a data source is geocoded by area code. |
| migrations/1769777340048_geocode_ukc24_by_ukr18.ts | Backfills UKC24 in data_record.geocode_result based on UKR18 prefix. |
| bin/cmd.ts | Registers the importCountries CLI command. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| ); | ||
| if (!fs.existsSync(countriesGeojsonPath)) { | ||
| logger.error( | ||
| `File not found: ${countriesGeojsonPath}. Download from https://www.data.gov.uk/dataset/96f3e623-6e54-4df2-808c-48dba5c98b55/countries-december-2021-boundaries-uk-bgc`, |
There was a problem hiding this comment.
The missing-file message points to the “countries December 2021 boundaries” dataset, but this importer expects CTRY24CD/CTRY24NM properties (and the area set code is UKC24). Downloading the linked 2021 dataset is very likely to produce different property names and make the import fail or insert null codes. Update the URL/message to match the expected 2024 country boundaries (or update the expected property names to match the intended source).
| `File not found: ${countriesGeojsonPath}. Download from https://www.data.gov.uk/dataset/96f3e623-6e54-4df2-808c-48dba5c98b55/countries-december-2021-boundaries-uk-bgc`, | |
| `File not found: ${countriesGeojsonPath}. Download from https://www.data.gov.uk/dataset/96f3e623-6e54-4df2-808c-48dba5c98b55/countries-december-2024-boundaries-uk-bgc`, |
| ON CONFLICT (code, area_set_id) DO UPDATE SET geography = EXCLUDED.geography; | ||
| `.execute(db); | ||
|
|
||
| const percentComplete = Math.floor((i * 100) / count); |
There was a problem hiding this comment.
percentComplete never reaches 100% because it uses i (0-based) rather than the number of processed features. Use (i + 1) (or special-case the final iteration) so the last log shows 100% complete.
| const percentComplete = Math.floor((i * 100) / count); | |
| const percentComplete = Math.floor(((i + 1) * 100) / count); |
75aef3f to
1068632
Compare
No description provided.