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
@@ -1,6 +1,7 @@
|
||||
-- set_registration_checked_in: admin flips checked_in; un-checking removes the
|
||||
-- attendee's check-in points (and only those). Run inside a transaction that
|
||||
-- is rolled back, like the other suites.
|
||||
-- set_registration_checked_in: admin flips checked_in. Un-checking removes the
|
||||
-- attendee's check-in points (and only those); re-checking restores the points
|
||||
-- that the surviving check-in rows justify, without letting repeated clicks
|
||||
-- farm points. Run inside a transaction that is rolled back, like other suites.
|
||||
\set ON_ERROR_STOP on
|
||||
begin;
|
||||
|
||||
@@ -95,17 +96,97 @@ select pg_temp.assert_scr(
|
||||
'other attendee keeps their points');
|
||||
|
||||
-- -----------------------------------------------------------------------------
|
||||
-- 3. Re-checking does not re-award anything.
|
||||
-- 3. Re-checking RESTORES the points the surviving check-in rows justify.
|
||||
-- Section 1 deleted the audit rows but the attendance records remain, so the
|
||||
-- old behaviour (award nothing, permanently) left this person 30 points short
|
||||
-- with no way back. Toggling on now recomputes from the rows: 10 per session
|
||||
-- check-in + 10 for the front desk.
|
||||
-- -----------------------------------------------------------------------------
|
||||
-- Real attendance for scr-user: two sessions. Negative slot ids keep these
|
||||
-- fixtures out of every real event's schedule.
|
||||
insert into public.slots (id, event_id, name, slot_date, start_time, end_time, type)
|
||||
values (-152001, 'c7e10000-0000-0000-0000-000000000001', 'SCR Talk A', current_date, '09:00', '10:00', 'session');
|
||||
insert into public.sessions (id, event_id, slot_id, title)
|
||||
values ('c7e10000-0000-0000-0000-0000000000a1', 'c7e10000-0000-0000-0000-000000000001', -152001, 'SCR Session one'),
|
||||
('c7e10000-0000-0000-0000-0000000000a2', 'c7e10000-0000-0000-0000-000000000001', -152001, 'SCR Session two');
|
||||
insert into public.checkins (event_id, contact_email, session_id, staff_email)
|
||||
values ('c7e10000-0000-0000-0000-000000000001', '[email protected]', 'c7e10000-0000-0000-0000-0000000000a1', '[email protected]'),
|
||||
('c7e10000-0000-0000-0000-000000000001', '[email protected]', 'c7e10000-0000-0000-0000-0000000000a2', '[email protected]');
|
||||
|
||||
create temporary table scr_on as
|
||||
select * from public.set_registration_checked_in(
|
||||
'c7e10000-0000-0000-0000-000000000011', true);
|
||||
select pg_temp.assert_scr(
|
||||
(select checked_in = true and points_removed = 0 from scr_on),
|
||||
're-check-in awards no points');
|
||||
(select checked_in = true and points_removed = 0 and points_added = 30 from scr_on),
|
||||
're-check-in restores 30 points (2 sessions + front desk)');
|
||||
select pg_temp.assert_scr(
|
||||
(select points = 10 from public.registrations where qr_token = 'SCRQR-1'),
|
||||
'points unchanged after re-check-in');
|
||||
(select points = 40 from public.registrations where qr_token = 'SCRQR-1'),
|
||||
'points back to the pre-uncheck total after re-check-in');
|
||||
select pg_temp.assert_scr(
|
||||
(select points = 40 from public.leaderboard
|
||||
where event_id = 'c7e10000-0000-0000-0000-000000000001' and contact_email = '[email protected]'),
|
||||
'leaderboard synced back up to 40');
|
||||
|
||||
-- Toggling on again is idempotent: the award already matches what the rows
|
||||
-- justify, so repeated clicks cannot farm points.
|
||||
create temporary table scr_on2 as
|
||||
select * from public.set_registration_checked_in(
|
||||
'c7e10000-0000-0000-0000-000000000011', true);
|
||||
select pg_temp.assert_scr(
|
||||
(select points_added = 0 from scr_on2),
|
||||
'second re-check-in awards nothing (not farmable)');
|
||||
select pg_temp.assert_scr(
|
||||
(select points = 40 from public.registrations where qr_token = 'SCRQR-1'),
|
||||
'points unchanged by a repeat toggle on');
|
||||
|
||||
-- Full round trip is symmetric: off removes exactly what on gives back.
|
||||
create temporary table scr_off3 as
|
||||
select * from public.set_registration_checked_in(
|
||||
'c7e10000-0000-0000-0000-000000000011', false);
|
||||
select pg_temp.assert_scr(
|
||||
(select points_removed = 30 from scr_off3),
|
||||
'un-check-in again removes the same 30');
|
||||
create temporary table scr_on4 as
|
||||
select * from public.set_registration_checked_in(
|
||||
'c7e10000-0000-0000-0000-000000000011', true);
|
||||
select pg_temp.assert_scr(
|
||||
(select points_added = 30 from scr_on4),
|
||||
'and toggling on restores it once more');
|
||||
|
||||
-- Someone with attendance but no session check-ins at all earns only the
|
||||
-- front-desk +10 on the way back on (SCRQR-2 has connection points, no rows).
|
||||
create temporary table scr_on3 as
|
||||
select * from public.set_registration_checked_in(
|
||||
'c7e10000-0000-0000-0000-000000000012', true);
|
||||
select pg_temp.assert_scr(
|
||||
(select points_added = 10 from scr_on3),
|
||||
'front-desk-only restore awards 10');
|
||||
select pg_temp.assert_scr(
|
||||
(select points = 35 from public.registrations where qr_token = 'SCRQR-2'),
|
||||
'front-desk +10 lands on top of connection points');
|
||||
|
||||
-- -----------------------------------------------------------------------------
|
||||
-- 3b. Staff and Admin-domain contacts stay at zero in both directions.
|
||||
-- -----------------------------------------------------------------------------
|
||||
insert into public.contacts (email, full_name, is_admin)
|
||||
values ('[email protected]', 'SCR Staff', false);
|
||||
insert into public.registrations (id, event_id, contact_email, type, qr_token, checked_in, points)
|
||||
values ('c7e10000-0000-0000-0000-000000000013', 'c7e10000-0000-0000-0000-000000000001',
|
||||
'[email protected]', 'staff', 'SCRQR-3', true, 0);
|
||||
insert into public.checkins (event_id, contact_email, session_id, staff_email)
|
||||
values ('c7e10000-0000-0000-0000-000000000001', '[email protected]', 'c7e10000-0000-0000-0000-0000000000a1', '[email protected]');
|
||||
create temporary table scr_staff_off as
|
||||
select * from public.set_registration_checked_in(
|
||||
'c7e10000-0000-0000-0000-000000000013', false);
|
||||
create temporary table scr_staff_on as
|
||||
select * from public.set_registration_checked_in(
|
||||
'c7e10000-0000-0000-0000-000000000013', true);
|
||||
select pg_temp.assert_scr(
|
||||
((select points_removed = 0 from scr_staff_off) and (select points_added = 0 from scr_staff_on)),
|
||||
'staff toggle moves no points in either direction');
|
||||
select pg_temp.assert_scr(
|
||||
(select points = 0 from public.registrations where qr_token = 'SCRQR-3'),
|
||||
'staff registration stays at zero');
|
||||
|
||||
-- -----------------------------------------------------------------------------
|
||||
-- 4. Unknown registration id is rejected.
|
||||
|
||||
Reference in new issue
Block a user