feat: add manual feedback AI summaries and secure leaderboard scoring
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
407b878e23
commit
821907b164
37 files changed
+1640
-77
No files matched your search
+20
-10
@@ -33,22 +33,31 @@ Source of truth:
|
||||
| Feedback — rating + comment | **+10** | the attendee |
|
||||
| Admin adjustment | any | the target (audited as `admin`) |
|
||||
|
||||
Only eligible registered participants earn points. Staff registrations and Admin
|
||||
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.
|
||||
|
||||
## Internal helpers
|
||||
|
||||
### `_award_points(p_event_id, p_contact_email, p_delta, p_category)`
|
||||
The single place points change. In one transaction it:
|
||||
The shared award path first locks the registration and checks eligibility. Missing
|
||||
registrations, staff and Admin contacts receive no award or new audit entry.
|
||||
Clients cannot call this helper directly. In one transaction it:
|
||||
1. `update registrations set points = greatest(0, points + p_delta)` (floored at
|
||||
0) for the (event, contact),
|
||||
2. `insert into points_log (event_id, contact_email, delta, category)`,
|
||||
3. calls `_sync_leaderboard(p_event_id, p_contact_email)`.
|
||||
3. synchronizes the leaderboard through the registration write trigger.
|
||||
|
||||
### `_sync_leaderboard(p_event_id, p_contact_email)`
|
||||
Upserts the `leaderboard` row for that (event, contact) from `registrations` +
|
||||
`contacts` (`on conflict (event_id, contact_email) do update ...`). This is what
|
||||
makes the leaderboard a consistent, Realtime-friendly mirror. **Staff are
|
||||
excluded:** if the contact's registration `type` is `staff` (or there is no
|
||||
registration), the function **deletes** any existing leaderboard row instead of
|
||||
inserting — so staff never appear on the board even if they hold points.
|
||||
makes the leaderboard a consistent, Realtime-friendly mirror. **Staff, Admins and
|
||||
missing registrations are excluded:** the function deletes existing excluded
|
||||
rows. Registration writes force excluded balances to zero; role/point changes,
|
||||
registration deletion, contact Admin promotion and name changes refresh rankings.
|
||||
The zero-points guard runs after the existing role-normalization triggers.
|
||||
`leaderboard` belongs to the `supabase_realtime` publication for live updates.
|
||||
|
||||
### `_recalc_event_aggregates(p_event_id)`
|
||||
Recomputes the `events` aggregate columns (`num_sessions`, `num_speakers`,
|
||||
@@ -59,7 +68,7 @@ triggers and the feedback RPC.
|
||||
|
||||
| Function | Returns | Used for |
|
||||
|---|---|---|
|
||||
| `get_leaderboard()` | `event_id, contact_email, full_name, points` (active event, **staff excluded**, ordered by points) | Leaderboard initial load + realtime re-fetch |
|
||||
| `get_leaderboard()` | `event_id, contact_email, full_name, points` (active event, **staff/Admins excluded**, ordered by points descending, name and email ascending) | Leaderboard initial load + realtime re-fetch |
|
||||
| `lanyard_lookup(p_qr_token)` | `email, full_name, linkedin_url` (null unless `show_linkedin`), `show_email`, `registration_type` | Resolve a scanned QR (pre-login + connect) |
|
||||
| `get_public_contacts()` | `email, full_name, linkedin_url`, `show_email`, `registration_type` (active-event registrants) | Connections name/type lookups |
|
||||
| `get_agenda()` | flat rows: slot fields + session fields + `speakers` (string_agg) | Agenda + Home |
|
||||
@@ -238,9 +247,10 @@ immediately.
|
||||
`p_type` is `text` and is cast to the `registration_type` enum on write.
|
||||
|
||||
### `evaluate_session_feedback(p_session_id)` → `sessions`
|
||||
**Admin-only.** The **AI-feedback stub**: sets `ai_generated_feedback` to a
|
||||
placeholder string ("AI evaluation stub: N comment(s) received. (LLM integration
|
||||
pending.)"). Real LLM integration is a later phase.
|
||||
**Deprecated stub.** Migration `20261011163332_feedback_ai_summaries` revokes
|
||||
client execution. Admin now uses the authenticated sidecar for real manual event
|
||||
and session summaries, stored separately from `sessions.ai_generated_feedback`.
|
||||
See [Feedback AI summaries](./feedback-ai.md).
|
||||
|
||||
### `set_session_material(p_session_id, p_material_path)` → `sessions`
|
||||
Sets only a session's `material_path`, with a row lock. Requires authentication
|
||||
|
||||
Reference in new issue
Block a user