Summary
profiles already has city, region, countryId, latitude, longitude, and showOnMap columns, but latitude/longitude are never populated automatically — they exist only because someone manually wrote to them. A geocoding pipeline should run on profile address changes so map placement just works.
Requirements
Context
profiles.{city, region, countryId, latitude, longitude} already exist (packages/api/src/db/schema/users.ts:103-115). The map plumbing on the web app reads these — populating them is the missing link.
Pairs with #1969 (org-side addresses + geocoding) — same pipeline serves both.
Implementation Notes
Nominatim has a 1 req/sec public rate limit + a User-Agent header requirement; that's plenty for an admin PATCH but means the backfill script needs a setTimeout delay between calls. Mapbox is faster but needs an API key + budget. Decide once for both #1969 and this issue and reuse the same lib/geocode.ts.
Summary
profilesalready hascity,region,countryId,latitude,longitude, andshowOnMapcolumns, butlatitude/longitudeare never populated automatically — they exist only because someone manually wrote to them. A geocoding pipeline should run on profile address changes so map placement just works.Requirements
PATCH /me/profile(packages/api/src/routes/me.ts): whencity,region, orcountryIdchanges, enqueue or inline-call a geocoderPATCH /admin/users/:id(packages/api/src/routes/admin/users/byId.ts): same trigger when an admin edits the address fieldsprofiles.latitude/profiles.longitude; if the geocode fails (no result, rate-limited, network error) the existing lat/long stays put and we log the failureprofiles.geocoded_attimestamp records the last successful geocode — distinguishes "never tried" from "tried, no result"packages/api/scripts/geocode-profiles.tsfor the existing roster: iterate over profiles with city + country and no lat/longContext
profiles.{city, region, countryId, latitude, longitude}already exist (packages/api/src/db/schema/users.ts:103-115). The map plumbing on the web app reads these — populating them is the missing link.Pairs with #1969 (org-side addresses + geocoding) — same pipeline serves both.
Implementation Notes
Nominatim has a 1 req/sec public rate limit + a User-Agent header requirement; that's plenty for an admin PATCH but means the backfill script needs a
setTimeoutdelay between calls. Mapbox is faster but needs an API key + budget. Decide once for both #1969 and this issue and reuse the samelib/geocode.ts.