fix(points): welcome check-in awards +10; add Sessions view, AI connection test, silent reload
The front-desk check-in set checked_in and printed badges but awarded nothing, so the +10 depended on which check-in a person happened to get. Every award path was reviewed: - welcome_checkin awards +10 (category checkin) on a genuine first check-in and returns points + points_awarded; checkin_attendee and preview_welcome_checkin return points_awarded too. - set_registration_checked_in(false) deleted all checkin points while keeping the checkins rows, and switching back on awarded nothing -- one mistaken toggle destroyed those points permanently. ON now recomputes from the rows that still exist and awards only the shortfall: reversible, still unfarmable. - The staff/Admin/@appe.at exclusion stays (product decision) but is no longer silent: three-way points sheets in the scanner, "no points" with a tooltip in Registrations, and the Contacts points modal refuses to apply rather than letting adjust_points (void) no-op quietly. Also in this change: - admin silent refresh (5s poll + 500ms after writes) across all data views; Registrations patches in place so rows never slide under the cursor - Settings "Validate AI connection" via a new sidecar POST /llm-test verdict endpoint (never leaks the key, distinguishes "no usage block" from "off") - new Sessions view between Schedule and Activity: speakers, attendance, ratings, attendee filter, and one button that summarises every session with feedback (one request each, concurrency 3, UI blocked until all settle) - provider requests disable thinking through one shared body builder sending both reasoning_effort:"none" and chat_template_kwargs.enable_thinking SQL: 113 / 57 / 24 assertions (set_registration_checked_in section 3 was rewritten, it asserted the bug). Sidecar 34 unit tests. Full e2e 202 passed, 0 failed. Migration applied locally only -- not deployed. 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:
1 parent
cdb4793273
commit
d3083b7940
35 files changed
+2778
-154
No files matched your search
+46
-7
@@ -26,6 +26,7 @@ Source of truth:
|
||||
|
||||
| Action | Points | Awarded to |
|
||||
|---|---|---|
|
||||
| **Welcome (front-desk) check-in**, first time only | **+10** | the attendee |
|
||||
| Checked into a session (by staff) | **+10** | the attendee |
|
||||
| Connection accepted | **+5 each** | both people |
|
||||
| Connection accepted **with a shared talk** | **+`talk_networking_bonus` each** (per event, default 2, `0` = off) | both people (category `talk_networking`) |
|
||||
@@ -38,8 +39,31 @@ contacts (`is_admin` or `@appe.at`) always have zero points and never rank,
|
||||
including when checked in, leaving feedback, accepting connections or receiving
|
||||
manual adjustments. Existing audit history is retained when a role changes.
|
||||
|
||||
**That exclusion is deliberate and stays — but it is no longer silent.** It used
|
||||
to be invisible: a staff test check-in produced a bare `0` and looked like a
|
||||
broken feature. `_points_eligible` is now consulted by the callers that report
|
||||
outcomes, so every surface says why:
|
||||
|
||||
- `checkin_attendee` / `welcome_checkin` / `preview_welcome_checkin` return
|
||||
`points_awarded`, and the scanner renders "Checked in · staff earn no points"
|
||||
instead of claiming "+10 pts · now 0".
|
||||
- The admin Registrations table shows "— no points" with a tooltip on the rows
|
||||
the predicate excludes (`canEarnPoints` in
|
||||
[../frontend/admin-app.md](../frontend/admin-app.md) mirrors the SQL exactly),
|
||||
and the Contacts points modal refuses to apply an adjustment to such a contact
|
||||
rather than letting `adjust_points` (which returns `void`) no-op quietly.
|
||||
|
||||
## Internal helpers
|
||||
|
||||
### `_points_eligible(p_event_id, p_contact_email)` → `boolean`
|
||||
The single source of truth for "may this person earn points": the contact must
|
||||
have a registration in **that event**, with `registrations.type <> 'staff'`,
|
||||
`contacts.is_admin = false` and an email not ending in `@appe.at`. `_award_points`
|
||||
uses it as a gate, and the outcome-reporting RPCs use it to tell the UI whether an
|
||||
award actually happened — both halves read the same predicate, so a screen can
|
||||
never promise points the database would refuse. There is no second copy of the
|
||||
rule anywhere else; the admin app's client-side mirror is commented to that effect.
|
||||
|
||||
### `_award_points(p_event_id, p_contact_email, p_delta, p_category)`
|
||||
The shared award path first locks the registration and checks eligibility. Missing
|
||||
registrations, staff and Admin contacts receive no award or new audit entry.
|
||||
@@ -119,7 +143,7 @@ Accepts an **incoming** request.
|
||||
### `reject_connection(p_connection_id)` → `connections`
|
||||
Same guards as accept, but sets `status = 'rejected'`. No points.
|
||||
|
||||
### `checkin_attendee(p_session_id, p_attendee_qr)` → `(checkin_id, attendee_email, attendee_name, points, already)`
|
||||
### `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
|
||||
`staff or admin only`.
|
||||
@@ -139,7 +163,10 @@ Staff checks an attendee into a session.
|
||||
nothing returning id` — if no row was inserted, the attendee was **already
|
||||
checked in**: sets `already = true` and awards **no points**.
|
||||
- Otherwise awards **+10** to the attendee (category `checkin`).
|
||||
- Returns the attendee's current total points.
|
||||
- Returns the attendee's current total points, and `points_awarded` — whether
|
||||
that +10 actually landed. It is `false` for someone `_points_eligible`
|
||||
excludes, which is the only reason a fresh check-in pays nothing. Without it
|
||||
the scanner had to render "+10 pts · now 0" for a staff badge scan.
|
||||
|
||||
> **Implementation note:** the "already checked in" case is detected via the
|
||||
> `ON CONFLICT ... DO NOTHING returning id` (a `NULL` id means no-op), and the
|
||||
@@ -147,14 +174,22 @@ Staff checks an attendee into a session.
|
||||
> `return query` inside an `if` block would *not* terminate the function and would
|
||||
> double-award.
|
||||
|
||||
### `welcome_checkin(p_attendee_qr)` → `(attendee_email, attendee_name, already)`
|
||||
### `welcome_checkin(p_attendee_qr)` → `(attendee_email, attendee_name, already, points, points_awarded)`
|
||||
Staff **welcome** check-in: marks an attendee present at the **event** (distinct
|
||||
from `checkin_attendee`, which checks someone into a specific session).
|
||||
- **Role check:** `is_staff_or_admin()` or it raises `staff or admin only`.
|
||||
- Resolves the attendee by `qr_token` for the active event.
|
||||
- Sets `registrations.checked_in = true` (no points — that's the session
|
||||
check-in's job).
|
||||
- `already` is `true` if the attendee was already checked in to the event.
|
||||
- Sets `registrations.checked_in = true` and, on a **first** check-in, awards
|
||||
**+10** (category `checkin`) through `_points_eligible` + `_award_points`. The
|
||||
front desk is a real check-in, so it pays the same as a session scan; before
|
||||
this it paid nothing, which made "check me in" award different amounts
|
||||
depending on *which* check-in a person got. It is once-per-person because the
|
||||
`checked_in` flag already is, so repeating a welcome cannot farm points.
|
||||
- `already` is `true` if the attendee was already checked in to the event; in
|
||||
that case nothing is awarded and `points` is the unchanged total.
|
||||
- `points_awarded` says whether the +10 landed (false for excluded staff/Admin),
|
||||
so the result sheet can say "Checked in · staff earn no points" rather than
|
||||
claiming points that were never written.
|
||||
- On a **first** check-in (and only when the event has a badge layout), enqueues
|
||||
`events.badge_copies` identical `badge_print` jobs in the same transaction — the
|
||||
Pi worker prints exactly one label per job, so N jobs = N labels (see
|
||||
@@ -162,7 +197,7 @@ from `checkin_attendee`, which checks someone into a specific session).
|
||||
so a bad row can never flood the queue. A re-check-in (`already`) enqueues
|
||||
nothing. Manual reprint (`enqueue_badge_print`) still prints **one** label.
|
||||
|
||||
### `preview_welcome_checkin(p_attendee_qr)` → `(attendee_email, attendee_name, already, will_print, copies)`
|
||||
### `preview_welcome_checkin(p_attendee_qr)` → `(attendee_email, attendee_name, already, will_print, copies, points_awarded)`
|
||||
Read-only preview shown by the staff scanner **before** a welcome check-in is
|
||||
committed, so the confirmation popup can name the attendee and be honest about
|
||||
printing.
|
||||
@@ -178,6 +213,10 @@ printing.
|
||||
uses it to say "print their badge 3 times" instead of a fixed "this person's
|
||||
label", so it can never over- or under-promise.
|
||||
- Checks nobody in and enqueues nothing; it is a pure lookup.
|
||||
- `points_awarded` predicts the confirm's outcome — `true` only for a genuine
|
||||
first check-in by someone `_points_eligible`. The popup uses it to promise
|
||||
"Checking in awards +10 points" only when it is true, and to say "This person
|
||||
does not earn points (staff or organiser)" otherwise.
|
||||
|
||||
### `merge_tickets(p_source_id, p_target_id)` -> `jsonb`
|
||||
|
||||
|
||||
Reference in new issue
Block a user