TODO: Smart proximity — query Postgres instead of Overpass
Smart proximity — query Postgres instead of Overpass
What
Replace the Overpass-dependent
/locations/nearby endpoint with a Postgres spatial query against the pre-seeded mcdonalds_locations table. Haversine function already exists in services/geo.py.Why
With locations in Postgres, "Near Me" becomes:
SELECT * FROM mcdonalds_locations ORDER BY haversine(lat, lng, $1, $2) LIMIT 10. Sub-millisecond. Always works. No external API dependency.Approach
- New endpoint or refactored
/locations/nearby— queriesmcdonalds_locationstable - Haversine distance calculated in Python (already exists) or SQL
- Still cross-references user's saved locations for slot info (existing match logic)
- Frontend: no changes needed if response shape stays the same
- Overpass client becomes optional — only used for seed/refresh, never runtime
Depends on
todo-mcd-preseed-locations — needs the table populated first.