Skip to content

fix: cursor pagination on events index repeating same rows - #47

Merged
jeroenbourgois merged 1 commit into
masterfrom
fix/events-cursor-pagination
Apr 25, 2026
Merged

fix: cursor pagination on events index repeating same rows#47
jeroenbourgois merged 1 commit into
masterfrom
fix/events-cursor-pagination

Conversation

@jeroenbourgois

Copy link
Copy Markdown
Member

The Flop schema sorted on [:inserted_at, :id] but search_events/2 selected a partial field list that did not include inserted_at. The extracted cursor therefore had inserted_at: nil, which Flop's Ecto adapter drops, leaving only id > cursor_id as the cursor predicate. Combined with the manually-prepended order_by(desc: timestamp) (which Flop was already warning about), each "Next" click peeled one record off the bottom of the same set instead of advancing.

Have Flop own the ordering and base the cursor on [:timestamp, :id] — both already in the SELECT — and replace the leftover (timestamp, inserted_at, id) index with a (timestamp, id) one that matches the new ORDER BY.

The Flop schema sorted on `[:inserted_at, :id]` but `search_events/2`
selected a partial field list that did not include `inserted_at`. The
extracted cursor therefore had `inserted_at: nil`, which Flop's Ecto
adapter drops, leaving only `id > cursor_id` as the cursor predicate.
Combined with the manually-prepended `order_by(desc: timestamp)` (which
Flop was already warning about), each "Next" click peeled one record off
the bottom of the same set instead of advancing.

Have Flop own the ordering and base the cursor on `[:timestamp, :id]` —
both already in the SELECT — and replace the leftover
`(timestamp, inserted_at, id)` index with a `(timestamp, id)` one that
matches the new ORDER BY.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@jeroenbourgois
jeroenbourgois merged commit ee10043 into master Apr 25, 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.

1 participant