- input.emailwhat the caller gives
- same_emaila value it works out
- Signupa record type
- Signupan attribute of a record or an answer
- "waiting"a fixed text or number
- toa part of an email or a payment
- Refusewhere it says no
Find the Signup whose email is the given email address.When one matches, refuse with "This address is already on the list".
same_email is
Count Signups where
email is input.email
When same_email is more than 0
Refuse "This address is already on the list"
Make a new referral code of 8 random letters and digits.
code is a random code of 8 letters and digits
The person's number is the count of Signups plus one.
signups is
Count all Signups
place is signups + 1
When a referral code was given, find the Signup whose referral_code is that code.When one matches, add 1 to that Signup's friends and take 5 off its score.A code that matches nobody is ignored, and the person still joins.
A friend's code moves its owner up, because a person who brings friends is worth more at launch.
When input.referral_code is given
referrer is
Find the first Signup where
referral_code is input.referral_code
when none carry on without one
When referrer holds a value
Change the Signup where
id is referrer.id
set friends to referrer.friends + 1
set score to referrer.score - 5
Create a Signup with email and name set to the given email address and name, referral_code set to the new code, referred_by set to the given referral code, friends set to 0, number and score set to the person's number, and state set to waiting.
Add a Signup
set email to input.email
set friends to 0
set name to input.name
set number to place
set referral_code to code
set referred_by to input.referral_code
set score to place
set state to "waiting"
Email the given address with the subject "You are on the list", saying their place and their own link, which is the site address with ?ref= and their referral code on the end.
Send an email
to input.email
template "Join the Waitlist Email"
place place as a number
referral_code signup.referral_code
value the setting SITE_ADDRESS
Answer with the person's number as the place, and the new referral code.
Answer
place is place
referral_code is code