Skip to content

Prevent duplicate Nominatim requests during proximity searches - #183

Merged
andreagrandi merged 2 commits into
masterfrom
fix-nominatim-proximity-requests
Aug 10, 2026
Merged

Prevent duplicate Nominatim requests during proximity searches#183
andreagrandi merged 2 commits into
masterfrom
fix-nominatim-proximity-requests

Conversation

@andreagrandi

@andreagrandi andreagrandi commented Aug 10, 2026

Copy link
Copy Markdown
Owner

Context

The map and list panels request proximity results concurrently. On a forward-geocode cache miss, both requests could contact Nominatim, while the default geopy adapter could also retry HTTP 429 responses immediately. This increased upstream traffic and delayed the existing keyword fallback.

What changed

  • Normalize and hash place/country lookup identities into backend-safe cache keys.
  • Use the shared Django database cache as a short-lived single-flight lock so concurrent callers reuse one geocoding result.
  • Cache unresolved and failed lookups for 60 seconds while retaining the existing six-hour successful-result cache.
  • Disable geopy transport retries so one elected lookup produces one upstream HTTP attempt.
  • Add focused coverage for normalized cache reuse, concurrent callers, retry configuration, and rate-limited failures.
  • Add a Chromium E2E that submits a proximity filter through the live Django server, overlaps the map/list requests, and verifies a single geocoding operation with consistent responses.

Notes / constraints

  • Existing map/list proximity responses and keyword fallback behavior are preserved.
  • Reverse geocoding is unchanged.
  • No API schema, database migration, dependency, template, or documentation changes are required.

Testing

  • nox -s tests — passed.
  • nox -s e2e -- tests/e2e/test_map.py::test_proximity_filter_deduplicates_concurrent_map_and_list_geocoding — full browser suite passed.
  • git diff --cached --check — passed before commit.

Closes #177

@andreagrandi
andreagrandi marked this pull request as ready for review August 10, 2026 14:46
@andreagrandi
andreagrandi merged commit 058a809 into master Aug 10, 2026
3 checks passed
@andreagrandi
andreagrandi deleted the fix-nominatim-proximity-requests branch August 10, 2026 15:22
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.

Prevent duplicate Nominatim requests during proximity searches

1 participant