Skip to content

fix: add deterministic tiebreaker to event list ordering - #1009

Open
decentraland-bot wants to merge 1 commit into
masterfrom
fix/deterministic-event-ordering
Open

fix: add deterministic tiebreaker to event list ordering#1009
decentraland-bot wants to merge 1 commit into
masterfrom
fix/deterministic-event-ordering

Conversation

@decentraland-bot

Copy link
Copy Markdown
Contributor

Summary

Why

PostgreSQL does not guarantee row order when the ORDER BY column has ties. Multiple events at the same location often share the same next_start_at, producing a random order on every query.

Test plan

  • All 199 existing unit tests pass
  • TypeScript compiles cleanly
  • Verify on staging: open the Genesis Plaza Events tab multiple times and confirm the order is stable

🤖 Generated with Claude Code

Events with the same next_start_at were returned in arbitrary order by
PostgreSQL, causing the Events tab to shuffle on every open (issue
decentraland/unity-explorer#9529). Adding e.id as a secondary sort key
guarantees a stable, reproducible order for all consumers.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

@decentraland-bot decentraland-bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Review verdict: PASS (no blocking findings). GitHub does not allow this account to approve a PR it authored, so I am leaving this as a review comment.

No P0/P1 issues found.

Findings:

  • Public API impact: backward-compatible. This only defines previously unspecified tie ordering for existing event list responses; request/response shape, filters, pagination parameters, and primary chronological/search-rank ordering remain unchanged.
  • Security: No security issues found. The added SQL fragment is static, and the existing raw orderBy / orderDirection values remain whitelist-derived.
  • Test coverage: A focused regression test for identical next_start_at values would be useful, but I do not consider it blocking for this one-line deterministic tie-breaker.
  • Git conventions: PR title and branch follow the semantic fix: convention.

CI status at review time: Prettier and lint-and-test are passing; build-image and integration-tests are still pending.


Reviewed by Jarvis 🤖 · Requested by Alejandro Jimenez (<@U0ADNDHL1T7>) via Slack

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.

Fix non-deterministic event ordering in Genesis Plaza map panel

1 participant