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:
lago committed 2026-10-20 22:15:29 +02:00
1 parent b7c2abb73b
commit 35b88d50ca
22 files changed
+809 -166

No files matched your search

+3 -2
View File
@@ -100,8 +100,9 @@ export function groupAgenda(rows: AgendaRow[]): { slot: Slot; sessions: Session[
}
/** Submit (or update) the current user's event-level feedback. */
export async function submitEventFeedback(rating: number, comment: string): Promise<void> {
await rpc('submit_event_feedback', { p_rating: rating, p_comment: comment });
export async function submitEventFeedback(rating: number, comment: string): Promise<{ feedback_id: string; points: number; earned: number }> {
const rows = await rpc<{ feedback_id: string; points: number; earned: number }[]>('submit_event_feedback', { p_rating: rating, p_comment: comment });
return rows[0];
}
/** Read the current user's own event-level feedback (null if not yet submitted). */
+2 -2
View File
@@ -53,8 +53,8 @@ export function EventFeedback({ onDone }: { onDone: () => void }) {
if (rating === 0) return;
setBusy(true);
try {
await submitEventFeedback(rating, comment.trim());
toast('Thanks for your feedback! ⭐', 'ok');
const res = await submitEventFeedback(rating, comment.trim());
toast(res.earned > 0 ? `Thanks! +${res.earned} pts ⭐` : 'Thanks for your feedback! ⭐', 'ok');
setSubmitted(true);
onDone();
} catch (e) {
+13 -3
View File
@@ -5,6 +5,16 @@ import { getLeaderboard } from '../lib/api';
import type { LeaderboardRow } from '../lib/types';
import { Avatar, Spinner } from '../components/ui';
/**
* Leaderboard display name: first name + the initial of the last name
* ("Max Muster" → "Max M.") — surnames stay private on a public screen.
*/
function maskedName(fullName: string): string {
const parts = fullName.trim().split(/\s+/).filter(Boolean);
if (parts.length < 2) return parts[0] ?? fullName;
return `${parts[0]} ${parts[parts.length - 1].charAt(0).toUpperCase()}.`;
}
export function Leaderboard() {
const { contact } = useAuth();
const [rows, setRows] = useState<LeaderboardRow[]>([]);
@@ -72,7 +82,7 @@ export function Leaderboard() {
return (
<div className="pod" key={r.contact_email}>
<div className={`bar ${cls}`}>{r.points}</div>
<div className="pname">{r.full_name.split(' ')[0]}</div>
<div className="pname">{maskedName(r.full_name)}</div>
<div className="ppoints">#{idx + 1}</div>
</div>
);
@@ -87,9 +97,9 @@ export function Leaderboard() {
return (
<div className={`lb-row ${isMe ? 'me' : ''}`} key={r.contact_email}>
<span className="rank">{rank}</span>
<Avatar name={r.full_name} id={r.contact_email} size={38} fs={13} />
<Avatar name={maskedName(r.full_name)} id={r.contact_email} size={38} fs={13} />
<div className="grow">
<div style={{ fontWeight: 700, fontSize: 14 }}>{r.full_name} {isMe && <span className="muted small">(you)</span>}</div>
<div style={{ fontWeight: 700, fontSize: 14 }}>{maskedName(r.full_name)} {isMe && <span className="muted small">(you)</span>}</div>
</div>
<span className="pts">{r.points}</span>
</div>