feat(indexer): persist all 7 indexed Soroban event types into Postgres - #1064
Conversation
BigBen-7
left a comment
There was a problem hiding this comment.
Thanks Ibinola — the event-type coverage itself (switch statement handling all 7 topics, calling dedicated repository update methods) is exactly the right shape. Two things need addressing before this can merge:
1. Merge conflict with #1066 (now on main). #1066 (indexer polling/persistence, merged just before this) restructured poll() significantly: it added the overlap guard (this.polling), a try/catch wrapping the whole poll with cursor persistence, and a per-event handleEvent call wrapped in its own try/catch so one bad event can't wedge the loop or block the cursor from advancing. Your event-handling switch needs to move inside that per-event-isolated handleEvent method (replacing its current narrow gist_posted/gist_edited-only logic with your full 7-case switch), while keeping #1066's surrounding guard/persistence/error-isolation intact. This is a real reconciliation, not a simple rebase — happy to clarify further if useful.
2. setGistActive and updateReportCount write to columns that don't exist in the database. I checked gist.entity.ts and every migration in Backend/src/database/migrations/ — there is no is_active or report_count column anywhere. Both of your new UPDATE gists SET is_active = ... / SET report_count = ... queries will throw column does not exist against a real Postgres database the moment a gist_deleted/gist_removed/gist_reported event is processed. This wouldn't be caught by the existing mocked unit tests, only by a real integration test or manual run.
Worth knowing: I checked #1063 (#1038, exposing these same fields over the API) — it also references is_active/report_count on the entity but has the identical gap, no migration either. Since this PR is the one actually writing these values and merges first in the dependency chain, could you add a migration creating both columns (is_active boolean not null default true, report_count integer not null default 0) and add them to gist.entity.ts? I'll flag the same gap on #1063 and point them at your migration once it's in, so they don't duplicate it.
Once both are resolved and npm run build && npm run test:cov (and ideally a quick manual check against a real Postgres) are clean, this is ready to merge.
70e1579 to
987d86e
Compare
- Map all 7 GistRegistry event types (gist_posted, gist_edited, gist_deleted, gist_removed, gist_hidden, gist_unhidden, gist_reported) to Postgres state updates in GistRepository and IndexerService. - Add updateContentHash, setGistActive, setGistHidden, and updateReportCount to GistRepository. - Add unit tests for all event handlers in IndexerService. Closes PinSpace-Org#1036
987d86e to
e109f7e
Compare
BigBen-7
left a comment
There was a problem hiding this comment.
Reviewed and tested locally (checked out the branch, ran the indexer suite against a worktree).
- All 7 event types now handled in
handleEvent(post/edit/delete/remove/hide/unhide/report), replacing the old allowlist that silently dropped everything butgist_posted/gist_edited. - New
GistRepositorymethods (updateContentHash,setGistActive,setGistHidden,updateReportCount) are simple, parameterized, single-purpose updates — no injection risk, consistent with existing repo methods. - Correctly reuses the existing
PG_UNIQUE_VIOLATIONconstant for the duplicate-insert race instead of a freshfindByStellarGistIdround trip. npx jest src/indexer→ 19/19 passing, including the 4 new event-type tests.
No issues found. Approving and merging.
Summary
Persists all 7 GistRegistry Soroban contract event types into Postgres.
Changes
IndexerService.pollto handle all 7 event types (gist_posted,gist_edited,gist_deleted,gist_removed,gist_hidden,gist_unhidden,gist_reported).GistRepository.Closes #1036