feat(points): staff auto-connect never scores; event feedback pays +5

- Migration 20261020120000: staff (type staff / Admin / @appe.at) are
  auto-connected to every participant of the event via connections.auto
  rows inserted directly as accepted - never through accept_connection,
  so zero points by construction; backfill + idempotent helper + trigger.
- Migration 20261020130000: submit_event_feedback awards +5 on the first
  submission per participant x event (edits earn 0), gated by
  _points_eligible; response gains earned column; ACL restored.
- Admin: points move from Contacts to Registrations (active-event rows
  only, in-place save); Dashboard Top points drops emails; Dashboard and
  Activity hide auto connections.
- Attendee: leaderboard masks surnames (Max M.); EventFeedback toast
  shows +5 pts on paid submissions.
- Tests: staff_auto_connections_tests.sql (14 assertions), rpc_tests
  section 11 (4 assertions). Docs + release record 2026-10-20.
- README: document the git-ignored .env provisioning step (missing key
  = white screen).

Co-authored-by: Stephan Charles <[email protected]>
Co-authored-by: Amelia Hernandez <[email protected]>
Co-authored-by: Markus Franz <[email protected]>
Co-authored-by: Sabrina Hota <[email protected]>
Co-authored-by: Nilüfer Doğan <[email protected]>
This commit is contained in:
committed 2026-10-20 22:15:29 +02:00
1 parent e243b83a56
commit 3ee91b5ad6
22 files changed
+809 -166

No files matched your search

+31
View File
@@ -143,6 +143,25 @@ Accepts an **incoming** request.
### `reject_connection(p_connection_id)` → `connections`
Same guards as accept, but sets `status = 'rejected'`. No points.
### Staff auto-connect (trigger, `20261020120000_staff_auto_connections.sql`)
Every staff member is connected to **every other participant of the same
event** without any user action — this is not an RPC:
- The staff set equals the points-exempt set (`_points_eligible`): registration
type `staff`, Admin contact, or an `@appe.at` address; everyone else is a
"person". Only staff × person pairs are created — never staff × staff.
- Rows are inserted as `status = 'accepted'`, `auto = true` by the trigger
`registrations_autoconnect_staff` (on registration insert / type change) and
by the idempotent backfill helper `_autoconnect_staff_event(event)`.
- **No points are ever awarded:** these rows never pass through
`accept_connection`/`_award_points`.
- Existing pairs (including a manually `rejected` one) are never touched — the
unique pair index makes every pass a no-op.
- Scanning a staff lanyard behaves as already-connected:
`create_connection_request`'s idempotency rule returns the existing
`accepted` row and the app shows "You're connected!".
- `auto = true` rows appear in the attendee's connections list but are excluded
from the admin Dashboard feed and the Activity connections table.
### `checkin_attendee(p_session_id, p_attendee_qr)` → `(checkin_id, attendee_email, attendee_name, points, already, points_awarded)`
Staff checks an attendee into a session.
- **Role check:** `is_staff_or_admin()` (i.e. `is_admin()`) or it raises
@@ -270,6 +289,18 @@ Post-session feedback.
- Recalculates `sessions.average_feedback`, updates the `ai_generated_feedback`
state machine, and recalcs the event aggregates.
### `submit_event_feedback(p_rating, p_comment)` → `(feedback_id, points, earned)`
Event-level feedback ("Rate this event" from Home), one row per (event, contact)
in `event_feedback`.
- Requires the caller to be **registered** for the active event; `rating` 1–5.
- **First submission earns +5** (category `feedback`, `_points_eligible` gate —
staff / Admin / `@appe.at` earn nothing).
- **Idempotent:** re-submitting upserts the row and earns **0** (an edit of an
already-rewarded answer never pays twice).
- `get_my_event_feedback()` returns the caller's existing answer for pre-fill.
- `20261020130000_event_feedback_points.sql` added the award + the `earned`
response column (drop/recreate — the return type changed; ACL restored).
### `adjust_points(p_contact_email, p_delta, p_reason)` → `void`
**Admin-only** manual points adjustment (category `admin`) for the active event.
Used by the APPE Admin console to award prizes or correct mistakes. Goes through
+21
View File
@@ -213,6 +213,15 @@ for the slot before inserting).
| `status` | `text` | `pending` \| `accepted` \| `rejected` (default `pending`) |
| `created_at` | `timestamptz` | |
| `resolved_at` | `timestamptz` | set when accepted/rejected |
| `auto` | `boolean` | staff auto-pairing (never hand-made, never scored) — `20261020120000_staff_auto_connections.sql` |
**Staff auto-connect:** the trigger `registrations_autoconnect_staff` inserts a
staff × person pair as `accepted`, `auto = true` whenever a registration is
created or changes type (plus a backfill in the migration). Staff here means
exactly the points-exempt set (`_points_eligible`): type `staff`, Admin contact,
or an `@appe.at` address. No points are ever awarded for these rows, and
existing pairs — including manually rejected ones — are never touched. The admin
console hides `auto` rows from its activity views.
**Constraint:** unique per **unordered pair per event** via
`unique index connections_pair_uniq on (event_id, least(from_email, to_email),
@@ -248,6 +257,18 @@ contact per session (prevents double points).
**Constraint:** `unique (event_id, contact_email, session_id)` — one feedback per
contact per session.
Points (awarded by `submit_feedback`, first submission only): **+5** rating
only, **+10** rating + non-empty comment.
## `event_feedback` — event-level rating
Same shape as `feedback` but `session_id` is replaced by
`unique (event_id, contact_email)` — one answer per participant per event,
upserted by `submit_event_feedback` (read by `get_my_event_feedback`).
Points: **+5** on the **first** submission only (edits earn nothing), gated by
`_points_eligible` — see `20261020130000_event_feedback_points.sql`.
## `leaderboard` — Realtime mirror
A public, Realtime-friendly mirror of points **per event**. **Not** the source of
+35
View File
@@ -740,7 +740,42 @@ configured API endpoint includes the services missing from Excel.
## Files
- [`supabase/tests/rpc_tests.sql`](../../supabase/tests/rpc_tests.sql) — the test
script (fixtures + assertions + summary).
- [`supabase/tests/run-rpc-tests.js`](../../supabase/tests/run-rpc-tests.js) — the
runner (executes the script, parses the summary, sets the exit code).
# Staff Auto-Connect + Leaderboard Masking Regression
Migration `20261020120000_staff_auto_connections.sql` (staff are auto-paired
with every non-exempt registration of the event as `accepted` + `auto = true`,
**never** through `accept_connection`, so **never for points**), plus the
Contacts → Registrations points move and the leaderboard name mask
(first name + last-name initial + dot). Re-verify the migration and run its
SQL suite — both safe on an already-applied database (everything rolls back):
```sh
docker exec -i supabase_db_Convivo psql -X -U postgres -d postgres \
-v ON_ERROR_STOP=1 < supabase/migrations/20261020120000_staff_auto_connections.sql
docker exec -i supabase_db_Convivo psql -X -U postgres -d postgres \
-v ON_ERROR_STOP=1 < supabase/tests/staff_auto_connections_tests.sql # 14 assertions
CONVIVO_BASE_URL=http://127.0.0.1:3000 npm test --prefix e2e -- leaderboard-live.spec.ts --project=chromium
CONVIVO_BASE_URL=http://127.0.0.1:3000 npm test --prefix e2e -- connections.spec.ts --grep CONV-CONN-007 --project=chromium
npm run test:rpc # section 11 covers submit_event_feedback: first submit +5, edit earns nothing, one points_log row, staff earns nothing (self-contained fixtures — green even with the seed drift below)
```
`leaderboard-live.spec.ts` pins the masked display: podium names are exactly
`Board P. / Board P. / Board T.` (rendering order 2nd-1st-3rd), the list shows
`Board F.`, and full names (`Board Player`, `Board Fourth`) must have count 0.
**CONV-CONN-007 was rewritten** by the feature itself: the old spec drove
*manual* staff networking (request → accept → decline), which the auto-pair
made impossible — scanning a staff lanyard now lands on an already-accepted
pair. The rewrite asserts pre-connected lists on both sides, the instant
"You're connected!" toast, `accepted|true` for the pair in the DB (`status`
and the new `auto` flag), and unchanged points plus zero `points_log` rows for
both parties. Its demo identities still ride the seed drift described in
[Full E2E Suite Status](#full-e2e-suite-status) (the whole connections file is
in that known-red list), so the SQL suite above is the real gate for the
backend guarantee.
+4 -4
View File
@@ -14,13 +14,13 @@ It runs on **port 3001** (Vite dev) or as the `convivo-admin` Docker container
| View | Purpose |
|---|---|
| **Dashboard** | Active event card (name, dates, location, aggregates: avg feedback, #sessions, #speakers, #registrations, #checked-in) + top points + recent activity. |
| **Contacts** | Table of all contacts (email, name, LinkedIn, visibility toggles, `is_admin`). Edit, toggle `is_admin`, set visibility, adjust points. (No QR token here — it lives on the registration.) A general search matches **first name, last name or email address**; the **LinkedIn**, **Visibility** and **Admin** columns each have an Excel-style **multi-select filter** with live counts. |
| **Registrations** | Per active event: list (contact, type, **QR token**, checked_in, points). Change type (enforces the sponsor rule — a failed sponsor change opens an **in-place sponsor lookup** popup), mark checked-in, **view the QR token** (final — no reset), and **preview the attendee's badge** (renders the event's badge layout with that row's own name / ticket type / QR token / company), plus a **Print** button that queues the badge on the print station ([../backend/printing.md](../backend/printing.md)). When the event has **no badge configured**, the Badge button stays visible but **grayed out**, and hovering it shows a tooltip explaining a badge must be designed first. A general search matches **first name, last name, email address or type**; the **Type**, **QR token** (ticket) and **Checked in** columns each have an Excel-style **multi-select filter** with live counts. The **checked-in toggle is per-row and optimistic**: it patches that one row (and its points) in place — **no list reload**, so rows never jump or vanish mid-edit (the list is sorted by points) — while a small "Saving…" pulse marks the busy row and only that checkbox is disabled; other rows stay live and a second row can be toggled concurrently. A rejected write rolls the row back to the server's values. Changing the type behaves the same way. The toggle is what grants front-desk eligibility from the console (see [../backend/rpcs.md](../backend/rpcs.md)). |
| **Dashboard** | Active event card (name, dates, location, aggregates: avg feedback, #sessions, #speakers, #registrations, #checked-in) + top points (**name only** — no email addresses are shown) + recent activity (staff auto-pairings are background bookkeeping, not activity, and never appear here). |
| **Contacts** | Table of all contacts (email, name, LinkedIn, visibility toggles, `is_admin`). Edit, toggle `is_admin`, set visibility. **Points are no longer managed here** — the value lives on the pass, so the adjustment moved to the **Registrations** row that owns it. (No QR token here — it lives on the registration.) A general search matches **first name, last name or email address**; the **LinkedIn**, **Visibility** and **Admin** columns each have an Excel-style **multi-select filter** with live counts. |
| **Registrations** | Per active event: list (contact, type, **QR token**, checked_in, points). Change type (enforces the sponsor rule — a failed sponsor change opens an **in-place sponsor lookup** popup), mark checked-in, **view the QR token** (final — no reset), and **preview the attendee's badge** (renders the event's badge layout with that row's own name / ticket type / QR token / company), plus a **Print** button that queues the badge on the print station ([../backend/printing.md](../backend/printing.md)). When the event has **no badge configured**, the Badge button stays visible but **grayed out**, and hovering it shows a tooltip explaining a badge must be designed first. A general search matches **first name, last name, email address or type**; the **Type**, **QR token** (ticket) and **Checked in** columns each have an Excel-style **multi-select filter** with live counts. The **checked-in toggle is per-row and optimistic**: it patches that one row (and its points) in place — **no list reload**, so rows never jump or vanish mid-edit (the list is sorted by points) — while a small "Saving…" pulse marks the busy row and only that checkbox is disabled; other rows stay live and a second row can be toggled concurrently. A rejected write rolls the row back to the server's values. Changing the type behaves the same way. The toggle is what grants front-desk eligibility from the console (see [../backend/rpcs.md](../backend/rpcs.md)). Points moved here from Contacts: each point-earning row of the **active** event carries a **Points** button (`adjust_points` always targets the active event's pass, so on other events the button is disabled with an explanatory tooltip), opening a modal that applies the delta, patches the row in place — no reload, no reordering — and lets the silent refresher settle the truth. Rows excluded from points (the `_points_eligible` mirror: type staff, Admin contact, `@appe.at`) show the "no points" marker and no button. |
| **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. |
| **Sessions** | Everything about the **active event's sessions** in one place (nav sits between Schedule and Activity): one row per session with its slot date/time, room / level / area, **speakers**, **check-in count** (with capacity when set), **average rating and response count**, and whether an AI summary is stored, **out of date**, or impossible. Click a row to expand it: description, the full **speaker list**, the **roster of who checked in** (with time and which staff member scanned them), and the stored **AI summary**. A **search** box matches title, room, level, area or speaker, and the **attendee filter** answers "which sessions did this person actually attend?" — the list narrows to those sessions, the header states the count, and the expanded roster highlights that person. **Generate AI Feedback Summary** (see below) summarises every session with feedback in one click. Data comes from `sessions` ⨝ `slots` ⨝ `session_speakers` ⨝ `checkins` ⨝ `feedback`, joined in the client so the numbers match the other views exactly and no new RLS policy is needed. |
| **Activity** | Tables of check-ins, connections, and feedback (per active event), with manual **Generate AI Summary** controls for the event and individual sessions. |
| **Activity** | Tables of check-ins, connections, and feedback (per active event; staff auto-pairings — `connections.auto` — are hidden here too), 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). |
| **Badges** | A **per-event WYSIWYG badge / PDF layout editor** (modelled on pretix's PDF Editor). Pick the event, then design one or more named **layouts** (a **Default** per event, switchable / creatable / deletable). Add **text boxes**, **QR codes** and **images** to a millimetre canvas; drag to move, use the 8 resize handles + rotation handle, **Shift-click to multi-select**, and **press `Del`** to remove. While dragging, **PowerPoint-style smart guides** appear — dashed alignment lines (edges / centres, page and neighbouring items) plus equal-spacing lines — and the element **snaps** to them. A **Word-style align** toolbar (left / center / right, top / middle / bottom) plus **PowerPoint-style** object alignment — align to the **page** or to the **selection**, and **distribute** horizontally / vertically — with the same controls in the properties panel. Text binds to attendee fields (name, email, ticket type, QR token, event name, **company / organizer**, or static) with font, size, line-height, colour, bold/italic, a labelled **Align text in box** section (horizontal left / center / right and vertical top / middle / bottom, inside the element's own frame) and case transform; QR binds to the token / check-in URL / email / name / static. **Undo/redo** (`Ctrl`+`Z` / `Ctrl`+`Y`, also `Ctrl`+`Shift`+`Z`), a **Preview** mode (no handles), a **JSON** view of the layout, and **Save**. Previewed against a real sample registration. See [../backend/rpcs.md#badge-editor](../backend/rpcs.md#badge-editor). |
| **Printing** | Badge-print control center: printer stations (add / inline **rename** / **revoke**, the `cvp_…` token shown **once** on creation), live station cards with state + staff hints, queue counters (pending / in flight / dead letters / completed), the last completed jobs with **Reprint**, and dead letters with **Requeue** / **Discard**. Backed by `get_print_overview` (polled every 5 s) — see [../backend/printing.md](../backend/printing.md). |
+17 -1
View File
@@ -332,12 +332,25 @@ Data: `getMyCheckins()` + `getTalkCohort()` + the agenda (via `useEvent()`).
A **full-screen takeover** (no tab bar), opened from the Agenda session sheet.
- Shows the session (slot · time · room · title).
- **1–5 star** rating + optional comment ("bonus points for details").
- **1–5 star** rating + optional comment — **+5 pts** rating only, **+10 pts**
rating + comment ("bonus points for details").
- On submit: `submitFeedback(sessionId, rating, comment)` → a success toast
("+N pts ⭐").
Data: `useEvent()` (session/slot) + `submitFeedback`.
## Event Feedback
A **full-screen takeover**, opened from Home ("Rate this event").
- **1–5 star** rating of the whole event + optional comment; one answer per
participant (`event_feedback`, pre-filled via `getMyEventFeedback()` when
already answered — re-submitting edits it).
- **First submission earns +5 pts** (edits earn nothing; staff/Admin/@appe.at
earn nothing) — toast "Thanks! +5 pts ⭐", plain thanks otherwise.
Data: `useEvent()` + `submitEventFeedback` / `getMyEventFeedback`.
## Leaderboard
The live leaderboard.
@@ -345,6 +358,9 @@ The live leaderboard.
- **Podium** for the top 3 (1st/2nd/3rd bars), then the rest as ranked rows.
- **Staff are excluded** — only attendees appear (enforced in
`get_leaderboard()` / `_sync_leaderboard`).
- **Names are masked** — first name + the initial of the last name plus a dot
(`Max Muster` → `Max M.`), on the podium and in the rows alike; surnames are
never rendered (`maskedName()` in `Leaderboard.tsx`).
- **Your row is highlighted** (`me`).
- **Live:** subscribes to Realtime `postgres_changes` on the `leaderboard` table
and re-fetches on any change — so it updates the moment points change anywhere.
+87
View File
@@ -0,0 +1,87 @@
# Staff Auto-Connect, Points Hygiene, Leaderboard Privacy (2026-10-20)
Three user-requested changes, one migration:
`20261020120000_staff_auto_connections.sql` (applied to the local stack,
**pending production**).
## 1. Staff are automatically connected to everyone — never for points
Every staff member now appears in every other participant's "My connections"
list for the same event, from the moment either registration exists — no
request, no accept step. **Connecting with staff never grants points** (the
explicit requirement): the rows are inserted directly as `accepted` and never
pass through `accept_connection`/`_award_points`.
- "Staff" is exactly the points-exempt set (`_points_eligible`): registration
type `staff`, Admin contact, or an `@appe.at` address. Everyone else is a
"person". Only staff × person pairs are created — never staff × staff,
never person × person.
- Trigger `registrations_autoconnect_staff` fires on registration INSERT and
on type changes (both directions: a late attendee pairs with existing staff,
a newly registered staff member pairs with everyone). `_autoconnect_staff_event(event)`
is the idempotent full pass, run once per event as the backfill.
- The unique pair index makes every pass conflict-free: an existing pair —
including a manually **rejected** one — is never touched.
- New column `connections.auto` (default `false`) marks these rows. Attendees
see them normally; the admin console (Dashboard activity feed, Activity
connections table) filters them out so counts stay honest.
- Scanning a staff lanyard is already-connected behaviour: `create_connection_request`
returns the existing `accepted` row and the app toasts "You're connected!".
## Points logic, as reviewed on 2026-10-20
Every award goes through `_award_points(event, email, delta, category)`, which
clamps at 0 (`greatest(0, points + delta)`), logs to `points_log`, and no-ops
without a registration unless `_points_eligible` holds — i.e. there is a
registration in **that** event with type ≠ `staff`, the contact is **not**
`is_admin`, and the email is **not** on `@appe.at`.
| Event | Who earns | Δ | category | Where |
|---|---|---|---|---|
| Welcome (front-desk) check-in | attendee | **+10** | `checkin` | `welcome_checkin` / `set_registration_checked_in` (un-toggling removes exactly what it added, as `admin`) |
| Session check-in | attendee | **+10** | `checkin` | `checkin_attendee` (once per session; service sessions excluded) |
| Connection accepted | both people | **+5 each** | `connection` | `accept_connection` |
| Talk networking bonus | both people | **+`events.talk_networking_bonus` each** | `talk_networking` | `accept_connection`, only if both attended the same session |
| Session feedback | attendee | **+5** rating only, **+10** rating + comment | `feedback` | `submit_feedback` (first submission only) |
| **Event feedback** | attendee | **+5** | `feedback` | `submit_event_feedback` — first submission only, added by `20261020130000_event_feedback_points.sql` |
| Admin adjustment | any eligible attendee | **±n** | `admin` | `adjust_points` (admin-only; **always the active event**) |
| **Staff connection (auto)** | **nobody** | **0** | — | trigger insert, never `accept_connection` |
## 2. Admin console: points belong to the pass, not the contact
- **Contacts**: the Points button + modal **removed** — a contact without a
pass cannot earn anything, so editing points there could silently do nothing.
- **Registrations**: eligible rows of the **active** event get a **Points**
button → the adjustment modal. On non-active events the button is disabled
with a tooltip because `adjust_points` always targets the active event's
pass. The save patches the row in place (no reload, no reorder) and the
silent refresher settles the truth — the same self-healing pattern as the
check-in toggle.
- **Dashboard "Top points"**: email addresses removed — name only.
- Dashboard feed + Activity hide `auto` connections.
## 3. Leaderboard names are masked
`Leaderboard.tsx` now renders **first name + last-name initial + dot**
("Max Muster" → "Max M.") on the podium *and* in the ranked rows (the podium
previously showed the bare first name; rows leaked the full surname). The
`(you)` marker still matches on the email, which never leaves the client.
## Verification
- `supabase/tests/staff_auto_connections_tests.sql` — **14 assertions green**
(pair creation both directions, staff×staff/people×people never paired,
**zero points_log rows and unchanged points**, late arrivals, rejected-pair
protection, idempotent re-run, type flip, helper revokes).
- Live local stack after the backfill: 678 auto rows, 6 staff in the active
event, **0 new `points_log` rows**.
- `npm run build` green for both apps.
- e2e: `leaderboard-live.spec.ts` now asserts the masked names (and that full
names do **not** appear). `connections.spec.ts` **CONV-CONN-007 rewritten** —
its old premise (manual staff networking, staff declining a request) is
obsolete by design: the feature pre-accepts those pairs. The rewrite asserts
pre-connected lists both ways, the instant-connect toast, `status|auto =
accepted|true` in the DB, and unchanged points for both parties. Like the
rest of that file it still rides the known seed drift (see
[../backend/tests.md](../backend/tests.md)); the backend guarantee is what
the SQL suite covers. Runbook: [../backend/tests.md](../backend/tests.md).
+1
View File
@@ -10,6 +10,7 @@ appended, so the record shows what was believed and when it was fixed.
| Date | Contents |
|---|---|
| [2026-10-20](./2026-10-20.md) | Staff auto-connected to everyone (never for points, `connections.auto`), points adjustment moved Contacts → Registrations with active-event guard, Dashboard top-points without emails, leaderboard names masked, event feedback pays +5 (session feedback confirmed +5/+10) — local stack applied, **production pending** |
| [2026-10-19](./2026-10-19.md) | Welcome-check-in confirmation + camera fixes; per-row check-in toggle, front-desk gate, badge copies — **deployed**; then points correctness (welcome +10, toggle restore, visible exclusions), Sessions view, AI connection test, silent refresh, tooltip containment, speaker pending-material deep link — **deployed**, incl. the corrected test numbers and the seed-drift diagnosis |
| [2026-10-18](./2026-10-18.md) | Badge print queue on the Pi stations |
| [2026-10-17](./2026-10-17.md) | Reports + event feedback work |