Place repo profile write methods + API handler extraction#96
Conversation
Extracts profile persistence out of the API handler inline transaction so both the API and the ingestion pipeline write through the same code. UpsertProfile always overwrites (API path). UpsertProfileIngestion skips rows where user_verified=true (ingestion path) and returns written=false so callers can count skips. PatchPlaceAccessibility delegates its write to UpsertProfile — same behaviour, existing integration suite unchanged. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Claude finished @koinsaari's task in 3m 53s —— View job PR Review
The refactor is clean and the test coverage is thorough. One behavioral regression in the audit log, one minor race worth noting. 🔴 Important — Audit action is always
|
wasCreate := input.ID == "" was always true because clients never send a profile ID — it's DB-generated. Now UpsertProfile returns (created bool) so the handler uses the actual insert/update outcome for the audit log. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Claude finished @koinsaari's task in 3m 42s —— View job PR Review
The previous 🔴 fix (returning 🔴 Important —
|
The created bool is what drives the audit action in the handler — not asserting it means a regression where created always returns false would go undetected. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Claude finished @koinsaari's task in 2m 21s —— View job PR Review
Both 🔴 findings from previous reviews are resolved. No new blocking issues. No blocking issues — previous fixes are correctPrevious 🔴 #1 — Audit action always Previous 🔴 #2 — 🟡 Nit — Place check and profile write are still non-atomic
What looks good
|
The existence check and profile insert now run in a single transaction. A deleted-between-calls place returns ErrPlaceNotFound instead of a FK constraint error, giving the handler a clean 404 path. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Claude finished @koinsaari's task in 2m 28s —— View job PR Review
No blocking issues — all three findings from previous review rounds are resolved. Previous findings: all resolved ✅🔴 #1 — Audit action always 🔴 #2 — 🟡 Nit — Place check and profile write non-atomic: Fixed in this push. Both the place-existence check ( What looks good
|
Summary
UpsertProfiletointernal/place— create-or-replace keyed onplace_id, always overwrites. This is the API write path.UpsertProfileIngestion— same but no-ops whenuser_verified=true, returns(written bool)for telemetry. This is the ingestion write path.PatchPlaceAccessibilityincmd/apito delegate its write toUpsertProfile. Engine orchestration, 404 check, and audit log entry stay in the handler. Behaviour unchanged — existing API integration suite passes unchanged.Test plan
go test ./...— all unit tests passgo test -tags integration ./internal/place/... -run "TestRepository_UpsertProfile|TestRepository_UpsertProfileIngestion"— 6 integration tests passgo test -tags integration ./cmd/api/...— 65 existing API integration tests pass unchangedgo vet ./...— cleanPart of #10.
🤖 Generated with Claude Code