feat(api): geocode member city/region to lat/long on save

Offen
#1,972 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Anfängerfreundlichkeit
35/100
Issue-Typ
Feature
Klarheit
Größtenteils klar
Aktivitätsstatus
Ruhig
Tech-Stack
typescript

Rechercherichtung

Read packages/api/src/routes/me.ts and packages/api/src/routes/admin/users/byId.ts, then inspect packages/api/src/db/schema/users.ts:103-115. Coordinate the Nominatim or Mapbox choice with #1969 before shaping the shared pipeline. Done means address changes and the backfill script populate coordinates, preserve existing values on failure, log failures, and record successful geocoding.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

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

  • On PATCH /me/profile (packages/api/src/routes/me.ts): when city, region, or countryId changes, enqueue or inline-call a geocoder
  • On PATCH /admin/users/:id (packages/api/src/routes/admin/users/byId.ts): same trigger when an admin edits the address fields
  • Geocoded values write to profiles.latitude / profiles.longitude; if the geocode fails (no result, rate-limited, network error) the existing lat/long stays put and we log the failure
  • A nullable profiles.geocoded_at timestamp records the last successful geocode — distinguishes "never tried" from "tried, no result"
  • Backfill script packages/api/scripts/geocode-profiles.ts for the existing roster: iterate over profiles with city + country and no lat/long
  • Geocoder choice (Nominatim vs Mapbox) decided in coordination with #1969 — orgs and members should use the same one

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.

Vorherrschende Sprache
HTML
Sterne
33
Forks
107
Ø Merge
14 Std. 6 Min.
Gemergte PRs (30 T.)
19

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus USRSE/usrse.github.io

Alle Issues in USRSE/usrse.github.io

Ähnliche Issues

Weitere Issues zu Backend & API Design

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.