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

Abierto
#1,972 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
5/5
Tiempo estimado
Más de una semana
Aptitud para principiantes
35/100
Tipo de issue
Nueva funcionalidad
Claridad
Bastante claro
Estado de actividad
Tranquilo
Stack tecnológico
typescript

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
HTML
Estrellas
33
Forks
107
Merge medio
14 h 6 min
PR fusionados (30 d)
19

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de USRSE/usrse.github.io

Todos los issues de USRSE/usrse.github.io

Issues similares

Más issues de Backend & API Design

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.