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).
This commit is contained in:
1 parent
b7c2abb73b
commit
35b88d50ca
22 files changed
+809
-166
No files matched your search
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in new issue
Block a user