How the conference's flows work¶
A flow is what d2 does when something happens: a message comes in, the rules that handle it run, and each can send more messages. Here most flows start from changes to the data: when an object is created or updated, d2 raises an event (diesel.entity.on.created, diesel.entity.on.updated), and a rule in Init hands it to the conference's own message.
1. A new registration¶
An attendee registers: a
Registrationis created.d2 raises
diesel.entity.on.created (category = "Registration", key = "r41").Init takes it:
$when diesel.entity.on.created (category, key) if (category is "Registration") { events.registered(id = key) }events.registered(events-registrations) counts the ticket, tells the organizers, and when the ticket type reaches its capacity marks it sold out and tells them that too.Every message goes through
events.notify(events-notify), the one place to change for real notices or email.
2. The double-booking guard¶
Two sessions can't be in the same room at the same time. events.clashes (events-programme) finds the sessions a session overlaps in its room:
dom.list(cls = "Session").data filter (o => o.id != id and o.room is s.room and toMillis(o.start as Date) < b and toMillis(o.end as Date) > a)
A flow runs after a save, so it can't stop the save itself. Instead, when a new session clashes, events.sessionAdded takes it out again and tells the organizers why; when a session is moved onto another, events.sessionMoved flags it (status: "clash") for them to fix.
Also¶
- Payments (events-registrations): a payment marks its registration paid, issues the invoice and the badge.
- Every day (events-days): a cron declared in Init reminds unpaid registrations, and the day before the event sends volunteers their shifts.
- On the day (events-onsite): check-ins, a warning when a room is over capacity, feedback requests after a session, and a summary when the event is closed.
To write your own: model it ($class), write the flow as your own message in a Spec: topic, try it in the fiddle with a Story:, then connect it with a trigger in Settings:Init or a cron.