Skip to content

Add bingo leaderboard API with live Pusher updates - #102

Merged
lnqminh3003 merged 1 commit into
backendfrom
feature/bingo-leaderboard
Apr 9, 2026
Merged

Add bingo leaderboard API with live Pusher updates#102
lnqminh3003 merged 1 commit into
backendfrom
feature/bingo-leaderboard

Conversation

@rxmox

@rxmoxrxmox commented Apr 6, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds the bingo leaderboard backend for the web organizer dashboard, giving real-time participant rankings during events.

New Endpoints

  • GET /api/events/:eventId/leaderboard - Returns sorted leaderboard with participant name, profile photo, connections count, lines completed, and completion status
  • PUT /api/events/:eventId/leaderboard/score - Lets participants update their bingo score (lines completed, sheet completion)

Leaderboard Display Format (per row)

ColumnDescription
UserProfile photo + name
ConnectionsUnique people connected with during bingo (computed from ParticipantConnection records)
Lines CompletedVertical, horizontal, and diagonal lines
CompletedBoolean flag for when entire sheet is filled (frontend can use for golden/ice-shattering visual)

Design Decisions

  • Connections count is computed at query time from existing ParticipantConnection records rather than stored, which avoids sync bugs and keeps data consistent
  • A<->B connections (regardless of direction) count as 1 unique partner per participant
  • Sort order: completed first, then most lines, then most connections
  • Client-trusted scores: mobile pushes linesCompleted and completed, no server-side game state verification needed for MVP

Real-Time Updates

  • leaderboard-updated Pusher event fires on score updates (from leaderboard controller) and connection create/delete (from participant connections controller)
  • Web dashboard subscribes and re-fetches the full leaderboard on each event

Files Changed

  • New: src/controllers/leaderboard_controller.ts
  • Modified: src/models/participant_model.ts (added linesCompleted, completed fields)
  • Modified: src/routes/event_routes.ts (wired 2 new routes)
  • Modified: src/controllers/participant_connections_controller.ts (Pusher triggers on create/delete)
  • Docs: Updated API reference, database schema, and real-time events guide

Implement GET /api/events/:eventId/leaderboard and PUT /api/events/:eventId/leaderboard/score
endpoints for the web organizer dashboard. Leaderboard shows participant name, profile photo,
connections count (computed from ParticipantConnection records), lines completed, and completion
status. Scores update via Pusher leaderboard-updated event for live refresh.
- Add linesCompleted and completed fields to Participant model
- Create leaderboard controller with getLeaderboard and updateScore
- Trigger leaderboard-updated Pusher event on score changes and connection create/delete
- Update API reference, database schema, and real-time events documentation
@lnqminh3003
lnqminh3003 merged commit f09e513 into backendApr 9, 2026
1 check passed
@rxmox
rxmox deleted the feature/bingo-leaderboard branch April 10, 2026 00:43
Sign up for freeto 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.

2 participants

@rxmox@lnqminh3003