Waitlist
When an event is full, put new people on a waitlist. If someone cancels, give their place to the first person waiting and email them.
The agent wrote a test that fills an event, cancels a place and checks who gets the email.
- Full
- A place opens
See the code app/lib/rsvp.lua
28function M.cancel(event_id) 29 local mine = eql.one("select rsvps { id, status } where .event_id = $id", { id = event_id }) 30 if not mine then return end 31 eql("delete rsvps where .id = $id", { id = mine.id }) 32 if mine.status ~= "going" then return end 33 34 local next = eql.unscoped([[ 35 select rsvps { id, .user_id.email as email, .user_id.name as name, 36 .event_id.title as title, .event_id.starts_at as starts_at, .event_id.venue as venue } 37 where .event_id = $id and .status = "waitlist" 38 order by .created_at, .id 39 limit 1 40 ]], { id = event_id })[1] 41 if not next then return end 42 43 eql.unscoped([[update rsvps set { status: "going" } where .id = $id]], { id = next.id }) 44 assert(mail.send { 45 to = next.email, 46 template = "promoted", 47 queue = true, 48 data = { 49 name = next.name:match("^%S+"), 50 title = next.title, 51 when = format.date(next.starts_at, "%A %d %B, %H:%M"), 52 venue = next.venue, 53 event_id = event_id, 54 }, 55 }) 56end




