feat: finalize ticket merging and speaker-aware imports

This commit is contained in:
Lago committed 2026-10-10 13:28:18 +02:00
1 parent 648daa0794
commit 4e71e9b797
35 files changed
+1772 -348

No files matched your search

+41
View File
@@ -139,6 +139,47 @@ from `checkin_attendee`, which checks someone into a specific session).
check-in's job).
- `already` is `true` if the attendee was already checked in to the event.
### `merge_tickets(p_source_id, p_target_id)` -> `jsonb`
Admin-only atomic merge of an imported, QR-less speaker/staff registration into
a purchased Pretix registration in the same event. The destination must have a
nonempty QR token and Pretix external ID. The source must have
`import_source = 'sessionize'`. New Excel imports record this explicitly; legacy
QR-less speaker/staff rows with imported contact IDs and no ticket external ID
are backfilled as Sessionize imports.
Locks event, registrations, contacts and session assignments. Inserts destination
speaker links before removing source links, preserving the last-speaker invariant.
Staff takes precedence over speaker; a destination sponsor registration adopts the
transferred role while its separate sponsor record remains intact. Destination QR,
email, points and attendance stay unchanged. Deletes only the source registration
and its event leaderboard mirror, never the contact/Auth account or another event.
Existing attendee activity on the source must be reconciled first; the RPC rejects
it rather than losing or duplicating history. Self-merges and merge chains fail.
The admin-readable, RLS-protected `ticket_merges` table retains an event-scoped
source-to-destination mapping and actor/time audit. Excel and API speaker imports
resolve that mapping, and later Pretix role updates preserve the merged role.
Returns source/destination registration IDs, destination email, role and the count
of transferred session assignments. There is no implicit check-in or points award.
Event registration/check-in aggregates now count only nonblank QR-bearing rows;
imported unticketed rows remain visible in Admin but do not increase ticket totals.
### Assigned Speaker Role
Registration writes resolve `attendee` to `speaker` whenever the same email has
an assignment to a regular `session` in that registration's event. This applies
to Pretix ticket inserts/updates, Excel imports and direct Admin changes, so a
regular purchased ticket cannot downgrade an assigned speaker on the next sync.
Assignments added or updated after ticket import also promote the registration.
Staff/sponsor roles retain their existing precedence; service-session links and
links in other events do not promote attendees. Unassigned attendees remain
attendees. The migration reconciles existing assigned attendees without changing
QR tokens, ticket identifiers, attendance, points or session links. Assignments
use exact contact email, not fuzzy name matches; different emails require the
explicit ticket merge workflow above.
### `submit_feedback(p_session_id, p_rating, p_comment)` → `(feedback_id, points, earned)`
Post-session feedback.
- **Requires the caller to be checked in** to that session (else raises).