Skip to content

Live voting#533

Open
katajakasa wants to merge 2 commits intomasterfrom
live-voting
Open

Live voting#533
katajakasa wants to merge 2 commits intomasterfrom
live-voting

Conversation

@katajakasa
Copy link
Member

@katajakasa katajakasa commented Mar 5, 2026

ref: #99

Summary

Adds live voting support for compos, replacing the old time-window-based voting mechanism. During a compo presentation, an admin reveals entries one by one (in order_index order), and the audience votes in real time.

Key changes

  • New model: LiveVotingState (one-to-one with Compo) tracks voting state, current on-screen entry, and last-updated timestamp
  • Entry fields: live_voting_revealed on Entry controls visibility during live voting
  • Removed fields: voting_start and is_votable from Compo (migration 0025)
  • Voting deadline: is_voting_open() checks both LiveVotingState.voting_open and voting_end, so voting is hard-blocked after the deadline even if an admin forgets to close it
  • Admin panel: New Live Voting view with real-time polling (1s when voting open, 5s when closed, + jitter), sequential reveal enforcement, and bulk reveal/hide/reset controls
  • Public entry visibility: Entries are shown if the event is archived, show_voting_results is enabled on the compo, OR the entry has been individually revealed via live voting

Public API

GET /api/v2/public/event/{event_id}/kompomaatti/live_voting/{compo_id}/

Supports If-Modified-Since for efficient polling. Returns 304 when unchanged.

{
  "compo": 3,
  "voting_open": true,
  "current_entry": 21,
  "updated_at": "2026-03-08T17:06:29.199433+00:00",
  "revealed_entries": [20, 21]
}
  • revealed_entries — entry IDs in order_index order
  • current_entry — the entry currently being presented (nullable)
  • voting_open — whether voting is accepting submissions

Admin API

All admin endpoints require staff permissions and return the full state with entry list.

Endpoint Method Description
.../live_voting/{compo_id}/ GET Get state (auto-creates if missing)
.../live_voting/{compo_id}/ PATCH Update voting_open / current_entry
.../live_voting/{compo_id}/reveal_entry/ POST Reveal a single entry {"entry_id": N}
.../live_voting/{compo_id}/hide_entry/ POST Hide a single entry {"entry_id": N}
.../live_voting/{compo_id}/reveal_all/ POST Reveal all entries
.../live_voting/{compo_id}/hide_all/ POST Hide all entries
.../live_voting/{compo_id}/reset/ POST Hide all, close voting, clear current entry

Notes

  • APIv1 is no longer consistent with this change and should be dropped
  • Admin UI enforces sequential reveals — only the next unrevealed entry (by order_index) can be revealed individually
  • Polling recommended at 1–2s + jitter for public clients

@katajakasa katajakasa changed the title Initial live voting code Live voting Mar 5, 2026
@katajakasa katajakasa force-pushed the live-voting branch 2 times, most recently from 03eeb00 to 94c84d3 Compare March 8, 2026 17:05
@katajakasa katajakasa marked this pull request as ready for review March 8, 2026 17:15
@katajakasa katajakasa force-pushed the live-voting branch 4 times, most recently from 97cf930 to 61b729f Compare March 9, 2026 20:13
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