Skip to content

feat: add global leaderboard#47

Merged
thomas-rx merged 1 commit intomainfrom
feature/backend-us-15-leaderboard
Mar 20, 2026
Merged

feat: add global leaderboard#47
thomas-rx merged 1 commit intomainfrom
feature/backend-us-15-leaderboard

Conversation

@thomas-rx
Copy link
Copy Markdown
Collaborator

Context

Add the global leaderboard API on top of final score submission.
Refs #15.

Changes

  • add GET /v1/leaderboard with a default limit of 10, a maximum of 50, and stable ranking by score and submission order
  • expose nickname, score, rank, and playedAt for accepted submissions only
  • add backend tests for ordering, limit handling, invalid limits, and OpenAPI exposure

@thomas-rx thomas-rx requested review from flaw03 and kvnpetit March 20, 2026 10:40
@thomas-rx thomas-rx changed the base branch from feature/backend-us-14-scores to main March 20, 2026 10:42
example: 1,
}),
nickname: z.string().openapi({
example: 'NeonHunter',
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

example non pertinant !

Comment on lines +68 to +83
SELECT rank, nickname, score, playedAt
FROM (
SELECT
ROW_NUMBER() OVER (
ORDER BY ss.score DESC, ss.submitted_at ASC, ss.id ASC
) AS rank,
COALESCE(NULLIF(p.display_name, ''), 'Anonymous') AS nickname,
ss.score AS score,
ss.submitted_at AS playedAt
FROM score_submissions ss
INNER JOIN players p
ON p.id = ss.player_id
)
ORDER BY rank
LIMIT ?
`
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

utilise un orm c'est sale

@thomas-rx thomas-rx merged commit 53e0f55 into main Mar 20, 2026
@thomas-rx thomas-rx deleted the feature/backend-us-15-leaderboard branch March 20, 2026 10:45
@kvnpetit kvnpetit added this to the MVP Backend milestone Mar 20, 2026
@kvnpetit kvnpetit added backend Backend, API ou infrastructure Cloudflare leaderboard Classement, profil joueur ou consultation des scores mvp Necessaire pour la premiere version jouable labels Mar 20, 2026
thomas-rx added a commit that referenced this pull request Mar 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend Backend, API ou infrastructure Cloudflare leaderboard Classement, profil joueur ou consultation des scores mvp Necessaire pour la premiere version jouable

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants