feat(places): promote confirmed OSM venue picks into the places catalogue - #119
Merged
Merged
Conversation
…ogue
Closes the remaining "search and creation" gap: geocodeAddress already
searched places.places first, falling back to Nominatim -- but a
Nominatim hit was used for exactly one event and then forgotten, never
making future searches for the same venue hit the DB tier.
ensurePlaceFromOsmSuggestion (src/app/actions/geocode.ts) now runs when
a host confirms an OSM/Nominatim suggestion in the location picker:
- Idempotent on sourceProvenance.legacyId ("<osmType>/<osmId>") -- the
same key the platform's own OSM ingestion pipeline uses, confirmed
against live places.places sample docs, so re-picking the same venue
never inserts a duplicate.
- Fetches the element's tags from the Overpass API (a single-element
lookup, not a wide search -- fast, low load) to infer a placeType
from the closed enum (tourism=hotel -> Accommodation, amenity=
restaurant -> Restaurant, shop=* -> Store, etc.), falling back to
LocalBusiness when Overpass is unreachable or the tag doesn't map.
- Writes a paired external/organization entity alongside the place
(Rule 10 -- every place needs an entity owner), mirroring the exact
shape every OSM-sourced row in the catalogue already has.
- Never throws -- a catalogue-write failure can't block whatever the
caller was actually doing (picking a venue for an event).
Verified both document shapes directly against the real production
places/entity validators (insert, confirm accepted, delete) before
wiring this up, since a malformed write to a schema owned by the wider
Mukoko platform is expensive to get wrong.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Sn4ULkV3dFFxEq5x3nCdaX
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
bryanfawcett
marked this pull request as ready for review
August 4, 2026 02:47
There was a problem hiding this comment.
Claude Code Review
This repository is configured for manual code reviews. Comment @claude review for a one-time review, or @claude review always to subscribe this PR to a review on every future push.
Tip: disable this comment in your organization's Code Review settings.
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
geocodeAddressalready searchedplaces.placesfirst and fell back to Nominatim, but a Nominatim hit was used for exactly one event and then forgotten — it never got promoted into the DB catalogue, so the next search for the same venue hit Nominatim again instead of the (much faster, richer) DB tier.ensurePlaceFromOsmSuggestionnow runs when a host confirms an OSM/Nominatim suggestion in the location picker (LocationModal). It's idempotent (keyed onsourceProvenance.legacyId, the same convention the platform's own OSM ingestion pipeline uses — verified against live sample docs), enriches the pick via a single-element Overpass API lookup to infer aplaceTypefrom the closed enum, and writes a paired external/organization entity alongside the place (every place needs an entity owner per the validator).places/entityAtlas validators (insert → confirm accepted → delete) before wiring this up, since a malformed write to a platform-owned schema is expensive to get wrong.Type of Change
Changes
src/app/actions/geocode.ts—ensurePlaceFromOsmSuggestion,fetchOverpassTags(Overpass single-element tag lookup),inferPlaceType(OSM tag →PlaceDoc.placeTypeenum mapping),osmType/osmIdadded toGeocodeSuggestion.src/components/ui/address-autocomplete.tsx— carriessource/osmType/osmIdthroughAddressComponents.src/components/modals/location-modal.tsx— callsensurePlaceFromOsmSuggestion(fire-and-forget) when an OSM-sourced suggestion is confirmed.src/app/actions/geocode.test.ts— idempotency, successful create + tag-basedplaceTypeinference, Overpass-unreachable fallback, and never-throws coverage.Test Plan
npm run test:run— 792 passed)ensurePlaceFromOsmSuggestion: 4 new cases)npm run lint)npm run build)Checklist
Generated by Claude Code