Skip to content

feat(indexer): persist all 7 indexed Soroban event types into Postgres - #1064

Merged
BigBen-7 merged 1 commit into
PinSpace-Org:mainfrom
Ibinola:feature/persist-indexer-events-1036
Aug 21, 2026
Merged

feat(indexer): persist all 7 indexed Soroban event types into Postgres#1064
BigBen-7 merged 1 commit into
PinSpace-Org:mainfrom
Ibinola:feature/persist-indexer-events-1036

Conversation

@Ibinola

@Ibinola Ibinola commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Summary

Persists all 7 GistRegistry Soroban contract event types into Postgres.

Changes

  • Updated IndexerService.poll to handle all 7 event types (gist_posted, gist_edited, gist_deleted, gist_removed, gist_hidden, gist_unhidden, gist_reported).
  • Added helper update methods to GistRepository.
  • Added unit tests for all event handlers.

Closes #1036

@BigBen-7 BigBen-7 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

- 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
@Ibinola
Ibinola force-pushed the feature/persist-indexer-events-1036 branch from 987d86e to e109f7e Compare August 20, 2026 13:16

@BigBen-7 BigBen-7 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 but gist_posted/gist_edited.
  • New GistRepository methods (updateContentHash, setGistActive, setGistHidden, updateReportCount) are simple, parameterized, single-purpose updates — no injection risk, consistent with existing repo methods.
  • Correctly reuses the existing PG_UNIQUE_VIOLATION constant for the duplicate-insert race instead of a fresh findByStellarGistId round trip.
  • npx jest src/indexer → 19/19 passing, including the 4 new event-type tests.

No issues found. Approving and merging.

@BigBen-7
BigBen-7 merged commit e46a7f2 into PinSpace-Org:main Aug 21, 2026
1 check passed
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.

Persist all 7 indexed event types into Postgres (reconciliation logic)

2 participants