Skip to content

Store place names in English - #233

Closed
engleek wants to merge 1 commit into
mainfrom
feat/english-place-names
Closed

engleek wants to merge 1 commit into
mainfrom
feat/english-place-names

Conversation

@engleek

@engleek engleek commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

Fixes #208.

The location picker (PlacesSearch → MapboxAutocomplete) queried Mapbox geocoding without a language, so Mapbox answered with each place's local name. Locations were saved as "Warszawa", "Genève" or "京都市", next to English ones.

Change

  • geocodingUrl(query, { token, types }) (app/utils/geocoding.js) builds every Mapbox geocoding request with language=en, and encodes the query. It handles reverse lookups too. The picker uses it, so new locations are stored in English.
  • scripts/backfill-place-names.mjs re-geocodes existing locations from their coordinates, in English. Usage is documented in its header:
    • it's a dry run by default, printing before → after; --write applies, and --limit N does a trial run;
    • it reads MAPBOX_TOKEN from the environment and never hard-codes it;
    • it paces itself (~5 requests/s), skips and logs failed or empty lookups, and keeps a name when English has none;
    • when renaming would make a row identical to another on the unique key, it re-points that row's orgs and events to the existing one and deletes it, in a transaction.
  • A latent crash: PlacesSearch referenced an undefined address whenever a result's context held an address (ReferenceError). It reads the context entry instead.
  • PhotonAutocomplete was unused (the issue first blamed it), so it's removed.

Running the backfill

MAPBOX_TOKEN=<the pk.… token> DATABASE_URL=<production> node scripts/backfill-place-names.mjs
MAPBOX_TOKEN=<the pk.… token> DATABASE_URL=<production> node scripts/backfill-place-names.mjs --write

Review the dry run's output before writing. I ran a 3-row dry run locally, and it worked. The seed's coordinates are random, so its renames on seed data mean nothing; on real data, names and coordinates match.

Tests

  • Unit: geocodingUrl (forward and reverse: language, types, encoding) and placeNames (reads the city and region from the features).
  • e2e: on /events/create, typing in Location sends a Mapbox request with language=en. The request is mocked, so CI never calls Mapbox. On main: it fails (language is missing).
  • Locally: the full e2e suite (38) and the unit and story tests (55) pass.

🤖 Generated with Claude Code

The location picker queried Mapbox without a language, which answers
with each place's local name, so locations were saved as "Warszawa",
"Genève" or "京都市" next to English ones.

- geocodingUrl() builds every Mapbox geocoding request with language=en
  (and encodes the query); the picker uses it.
- scripts/backfill-place-names.mjs re-geocodes existing locations from
  their coordinates: dry run by default, --write to apply, paced, and it
  merges a renamed row into an identical existing one.
- The place parser referenced an undefined `address` whenever a result's
  context held an address; it reads the context entry instead.
- PhotonAutocomplete was unused (the issue first blamed it); removed.

Fixes #208.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@engleek

engleek commented Oct 4, 2026

Copy link
Copy Markdown
Contributor Author

Superseded by #249, which merged this change into main.

@engleek engleek closed this Oct 4, 2026
@engleek
engleek deleted the feat/english-place-names branch October 9, 2026 20:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Data: place names mix languages

1 participant