Auto-RSVP when claiming a slot

Claiming a slot now also adds the person to the going list if they
aren't already there (case-insensitive name match).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-18 22:53:17 -04:00
parent 78ac8f3677
commit 087becdf58
3 changed files with 35 additions and 0 deletions
+3
View File
@@ -69,6 +69,9 @@ DELETE FROM rsvps WHERE id = ?;
-- name: CountRsvps :one
SELECT COUNT(*) FROM rsvps WHERE event_id = ?;
-- name: GetRsvpByName :one
SELECT * FROM rsvps WHERE event_id = ? AND name = ? COLLATE NOCASE LIMIT 1;
-- name: GetUserByPhone :one
SELECT * FROM users WHERE phone = ?;
+22
View File
@@ -321,6 +321,28 @@ func (q *Queries) GetEventBySlug(ctx context.Context, slug string) (Event, error
return i, err
}
const getRsvpByName = `-- name: GetRsvpByName :one
SELECT id, event_id, name, note, created_at FROM rsvps WHERE event_id = ? AND name = ? COLLATE NOCASE LIMIT 1
`
type GetRsvpByNameParams struct {
EventID int64
Name string
}
func (q *Queries) GetRsvpByName(ctx context.Context, arg GetRsvpByNameParams) (Rsvp, error) {
row := q.db.QueryRowContext(ctx, getRsvpByName, arg.EventID, arg.Name)
var i Rsvp
err := row.Scan(
&i.ID,
&i.EventID,
&i.Name,
&i.Note,
&i.CreatedAt,
)
return i, err
}
const getSession = `-- name: GetSession :one
SELECT token, user_id, expires_at FROM sessions WHERE token = ? AND expires_at > CURRENT_TIMESTAMP
`