Skip to content

Rewrite the leaderboard queries with the ORM - #417

Merged
danlamanna merged 1 commit into
gzip-middlewarefrom
leaderboard-orm-queries
Dec 1, 2026
Merged

danlamanna merged 1 commit into
gzip-middlewarefrom
leaderboard-orm-queries

Conversation

@danlamanna

Copy link
Copy Markdown
Member

Both queries now use window annotations instead of raw SQL, with the
same ROW_NUMBER partitions and orderings, so ranking and tie behaviour
are unchanged. The task filter moves inside the window scan, which is
safe because an approach belongs to one task, and avoids ranking every
submission in the database on each page view.

The base rules (succeeded, active creator, approach not rejected) are
now defined once in leaderboard_submissions() and shared with the
submission score endpoint.


Stack created with GitHub Stacks CLI • Give Feedback 💬

Both queries now use window annotations instead of raw SQL, with the
same ROW_NUMBER partitions and orderings, so ranking and tie behaviour
are unchanged. The task filter moves inside the window scan, which is
safe because an approach belongs to one task, and avoids ranking every
submission in the database on each page view.

The base rules (succeeded, active creator, approach not rejected) are
now defined once in leaderboard_submissions() and shared with the
submission score endpoint.
@danlamanna
danlamanna added this pull request to stack #418 December 1, 2026 16:23
@danlamanna
danlamanna merged commit 0370103 into master Dec 1, 2026
1 check passed
@danlamanna
danlamanna deleted the leaderboard-orm-queries branch December 1, 2026 16:28
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