feat: add admin raffle with confetti and top-3/staff exclusion
This commit is contained in:
1 parent
5117a25372
commit
3e2f8ff0ed
14 files changed
+680
-2
No files matched your search
@@ -95,11 +95,13 @@ A separate desktop-first React app for organizers, guarded to existing contacts
|
||||
with **`is_admin`** or an **`@appe.at`** email. See [frontend/admin-app.md](./frontend/admin-app.md):
|
||||
- **Views** — Dashboard (active event + aggregates), Contacts, Registrations,
|
||||
Sponsors, Schedule (slots/sessions/speakers/material), Activity (manual event
|
||||
and session AI summaries), Events, Interfaces, Reports and Settings.
|
||||
and session AI summaries), Raffle (attendee prize draws), Events, Interfaces,
|
||||
Reports and Settings.
|
||||
- **Auth guard** — email-only magic links; non-admin sessions are rejected.
|
||||
- **Key RPCs** — `reset_registration_qr_token` (regenerate a registration's
|
||||
lanyard token + sync the Auth password), `adjust_points`, `upsert_contact`,
|
||||
`create_registration`, `set_registration_type`, and `set_session_material`
|
||||
`create_registration`, `set_registration_type`, `set_session_material`, and the
|
||||
raffle functions `get_raffle_pool` / `draw_raffle_winner` / `reset_raffle`
|
||||
(see [backend/rpcs.md](./backend/rpcs.md)). The deprecated AI stub is no longer
|
||||
client-callable; generation uses authenticated [sidecar routes](./backend/feedback-ai.md).
|
||||
|
||||
|
||||
@@ -394,6 +394,31 @@ All are `security definer` so they can read `contacts` / `registrations` /
|
||||
|---|---|---|
|
||||
| `_assign_service_session_speakers(p_session_id, p_event_id)` | `integer` | Links **every registered staff member** of the event as a speaker of the given session (`on conflict do nothing`). Returns the number of rows affected. Called by both Sessionize sync RPCs for `service_session` sessions — a service session has no individual speaker, so the whole staff team "owns" it. |
|
||||
|
||||
## Raffle
|
||||
|
||||
Source: [20261015180640_raffle.sql](../../supabase/migrations/20261015180640_raffle.sql).
|
||||
|
||||
The admin **Raffle** view draws eligible attendees one at a time for the active
|
||||
event. Winner selection is authoritative **server-side** (random), so the client
|
||||
roulette animation only has to decelerate onto the returned name.
|
||||
|
||||
- `get_raffle_pool()` → `contact_email, full_name, points` — the eligible
|
||||
attendees: non-staff, non-Admin (`is_admin` or `@appe.at`), **not** in the
|
||||
leaderboard **top 3** (`get_leaderboard() limit 3`), and **not** already drawn
|
||||
in the current run. Returns `[]` for non-admins (guarded by `is_admin()`).
|
||||
- `draw_raffle_winner()` → `contact_email, full_name, points, draw_number` —
|
||||
**admin-only.** Picks one random eligible attendee, records them in
|
||||
`raffle_draws` with the next sequential `draw_number`, and returns the winner.
|
||||
Raises `No eligible attendees left to draw` when the pool is empty.
|
||||
- `reset_raffle()` → `void` — **admin-only.** Deletes the current run's winners
|
||||
for the active event so a new run can begin.
|
||||
|
||||
The `raffle_draws` table is keyed by `(event_id, contact_email)` (so an attendee
|
||||
can win at most once per run), cascades on event/contact deletion, and is
|
||||
admin-readable via RLS. All three functions are `security definer` with an empty
|
||||
`search_path`, revoke execution from `PUBLIC` / `anon`, and grant it back only to
|
||||
`authenticated` (the admin check is enforced inside each function).
|
||||
|
||||
## Error handling
|
||||
|
||||
RPCs raise Postgres exceptions with human-readable messages (e.g. `you cannot
|
||||
|
||||
@@ -1,3 +1,24 @@
|
||||
# Raffle Regression
|
||||
|
||||
After applying `20261015180640_raffle`, run:
|
||||
|
||||
```sh
|
||||
docker exec -i supabase_db_Convivo psql -X -U postgres -d postgres \
|
||||
-v ON_ERROR_STOP=1 < supabase/tests/raffle_tests.sql
|
||||
CONVIVO_ADMIN_URL=http://127.0.0.1:3001 npm test --prefix e2e -- raffle.spec.ts --project=chromium
|
||||
```
|
||||
|
||||
The SQL fixture is rollback-only: fifteen assertions cover the eligible pool
|
||||
(excluding staff, Admin, the `@appe.at` domain and the leaderboard top 3),
|
||||
sequential draw numbers, drawn attendees leaving the pool, the empty-pool
|
||||
over-draw error, winner persistence, run reset, and admin/non-admin/anon
|
||||
authorization. The browser suite is API-mocked and covers the default five
|
||||
picks, the decelerating roulette landing on a winner, drawing until the pick
|
||||
count, retry after a failed draw, starting a new run, a configurable pick
|
||||
count, and the mobile layout. No real LLM, email or points change is involved.
|
||||
|
||||
See [RPC rules](./rpcs.md#raffle) and the [Raffle view](../frontend/admin-app.md).
|
||||
|
||||
# Leaderboard Regression
|
||||
|
||||
After applying `20261015164546_leaderboard_staff_admin_exclusion`, run:
|
||||
|
||||
@@ -20,6 +20,7 @@ It runs on **port 3001** (Vite dev) or as the `convivo-admin` Docker container
|
||||
| **Sponsors** | List (paid only visible to attendees; admin sees all). Add/edit (type, name, email, phone, paid, amount, **contact search-and-pick**). |
|
||||
| **Schedule** | Slots (with a **type optionset** — `Session` / `Service Session`) + sessions (with speakers 1:N via a **multi-select search dropdown**, material upload with a **submitted / not submitted** state and `average_feedback`), plus an admin-only **Delete current schedule** action for the active event. |
|
||||
| **Activity** | Tables of check-ins, connections, and feedback (per active event), with manual **Generate AI Summary** controls for the event and individual sessions. |
|
||||
| **Raffle** | Draws eligible attendees one at a time for the active event. Configure the number of picks (default 5), then **Spin** a roulette that decelerates onto a server-chosen winner; repeat until the pick count is reached. Excludes staff/Admin and the leaderboard top 3, and no one can win twice in a run. **New run** clears the current winners. See [../backend/rpcs.md#raffle](../backend/rpcs.md#raffle). |
|
||||
| **Settings** | Global LLM endpoint, model and optional API key for feedback summaries. |
|
||||
| **Events** | Create event, toggle active/inactive (a switch; only one can be active at a time — activating one deactivates the rest), edit dates/location + the **Sessionize endpoint** + the **Real-time clock** toggle (on = the attendee app uses the real system clock for Live/Next/Done; off = the simulated mid-event clock, the default). Each row has a **Sync** button that runs a (blocking) Sessionize sync and shows a result modal. |
|
||||
| **Interfaces** | Manages the Sessionize sync **sidecar**: status (online / running / last run), a **Run sync** control (event picker + blocking run + result modal), an **Import Excel** control (upload the Sessionize "Sessions and speakers (advanced)" `.xlsx` + a "How to get this file" tooltip), and a **Recent runs** table from `sync_runs`. See [../backend/sidecar.md](../backend/sidecar.md). |
|
||||
|
||||
Reference in new issue
Block a user