Repository navigation
refactor(geo): use research area search across admin - #135
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Uses the persisted municipality/kommune catalog introduced in #134 as the canonical administrative-area search for Research and Operations. Selecting Flensburg now uses the same
admin.research_area.idand polygon in both workspaces.The shared accessible combobox provides bounded catalog search, country/region labels, 300 ms debounce, keyboard selection, cancellation and stale-response protection. A small read-only
GET /api/v1/research/areas/{id}/metadataendpoint hydrates selected values without loading dossier aggregates or boundary polygons.Before
admin.geo_areaimport.admin.research_areacatalog.After
admin.research_area; ordinary Operations search does not call Nominatim or create a Geo row.ST_Covers, boundary-point behavior, effective venue/space inheritance and per-view semantics remain intact. Operations organization location and Research organization event activity remain distinct questions.Compatibility
Uses option A: Operations retains
geo_scope_idas its compatible query parameter, carrying the exact Research UUID. Research retainsarea_id. This preserves existing endpoint, cursor, provenance and bookmark contracts without introducing competing Operations parameters.Legacy Geo UUIDs with a matching OSM relation resolve to the canonical Research polygon; the browser replaces the old UUID in the URL while preserving other filters. Unmatched arbitrary cached boundaries remain usable. Explicit legacy imports also reuse existing canonical municipalities without another provider request or duplicate geometry.
No migration, grant changes or data cleanup are needed; Alembic head remains
0016. Existingadmin.geo_arearecords are preserved. The in-memory preference store retains metadata only, with URL precedence and session clearing unchanged.Security
No authorization widening: Research catalog/metadata reads allow system admins or journalists; Operations remains system-admin-only. Nitro explicitly allowlists the UUID metadata route, GET only, without query passthrough. No Uranus writes, runtime grants, public geocoder fallback or new dependency.
Verification
backend/:.venv/bin/ruff check .— passed..venv/bin/ruff format --check .— 261 files passed; changed provenance files also rechecked after the final fix..venv/bin/mypy— 179 source files passed..venv/bin/pytest -qwithTEST_DATABASE_URLpointing at the isolated PostGIS database — 2,095 passed, one provenance projection mismatch found. Both explicit projection lists were corrected to includearea_id;.venv/bin/pytest -q tests/test_sql_provenance.pythen passed all 59 tests. The entire backend suite was not repeated after this narrowly scoped fix. No integration skips..venv/bin/pytest -q tests/test_geo.py tests/test_geo_analytics.py tests/test_research_areas.py tests/test_geocode.py tests/test_auth.py— 229 passed before the final additional venue-boundary cases; those cases passed in the full run..venv/bin/alembic heads—0016 (head).frontend/:pnpm lint— passed, four pre-existing warnings.pnpm typecheckandpnpm build— passed.pnpm test— 881 tests in 64 files passed. After the final focus/scroll adjustment,pnpm exec vitest run tests/unit/administrative-area-select.test.ts tests/unit/geo.test.tsalso passed all 18 tests.pnpm exec playwright test tests/e2e/geo-scope.spec.ts tests/e2e/research.spec.ts --workers=2 --output=/tmp/shared-area-e2e-dev-final— 44 passed after updating old searchbox assertions to the new combobox role. Geo analytics and geocoding also passed in the earlier combined development run; two production-only CSP cases were skipped there.TEST_PRODUCTION=1 pnpm exec playwright test tests/e2e/geo-scope.spec.ts tests/e2e/geo-analytics.spec.ts tests/e2e/research.spec.ts tests/e2e/geocoding.spec.ts --workers=2 --output=/tmp/shared-area-e2e-production— all 66 passed, no skips.git diff --check— passed. OpenAPI regenerated fromcreate_app(...).openapi()and checked by the backend contract test.Coverage includes canonical and legacy identity resolution, canonical polygon precedence, inside/outside/boundary venue membership, Operations endpoints without Nominatim configuration, unchanged effective-location regression tests, read-only metadata authorization, keyboard search, cancellation, stale response suppression, hydration, URL reload, legacy bookmark normalization, clearing, Research export/dossiers and geocoding CSP.
The integration database is disposable PostgreSQL 17/PostGIS, separate from application databases. Browser tests use synthetic fixtures; no production import or deployment was performed.