Skip to content

Commit

Permalink
Add membership lapse warning email, 7 days before suspension
Browse files Browse the repository at this point in the history
  • Loading branch information
Kimball Johnson committed Apr 18, 2016
1 parent b98b73e commit b3f3519
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
20 changes: 20 additions & 0 deletions bin/reconcile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ def send_email(address, subject, text)
mail.deliver
end

def send_lapse_warning_email(email, full_name, last_payment)
vars = {'name' => firstname(full_name),
'date' => last_payment.strftime('%Y-%m-%d')}
template = Erubis::Eruby.new(File.read('../emails/lapse_warning.erb'))
send_email(email, "Your London Hackspace membership will lapse in 7 days", template.result(vars))
end

def send_unsubscribe_email(email, full_name, last_payment)
vars = {'name' => firstname(full_name),
'date' => last_payment.strftime('%Y-%m-%d')}
Expand Down Expand Up @@ -97,6 +104,19 @@ def send_subscribe_email(email, full_name)
end
end

db.exec("SELECT users.*, (SELECT max(timestamp) FROM transactions WHERE user_id = users.id) AS lastsubscription
FROM users
WHERE users.subscribed = true
AND (SELECT max(timestamp) FROM transactions WHERE user_id = users.id) < now() - interval '1 month' - interval '7 days'
AND (SELECT max(timestamp) FROM transactions WHERE user_id = users.id) > now() - interval '1 month' - interval '8 days'"
) do |result|

result.each do |user|
puts "Warning #{user['full_name']} of membership soon to lapse"
send_lapse_warning_email(user['email'], user['full_name'], Time.parse(user['lastsubscription']))
end
end

db.exec("SELECT users.*, (SELECT max(timestamp) FROM transactions WHERE user_id = users.id) AS lastsubscription
FROM users
WHERE users.subscribed = true
Expand Down
32 changes: 32 additions & 0 deletions emails/lapse_warning.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
Dear <%=name%>,

This is an automated email sent from our payment system.

We haven't noticed a payment from you in over a month, and if we
do not within 7 days your membership will be automatically suspended, and your
door access will be disabled.

We last received a payment from you on <%=date%>.

If you believe we are warning you in error, please reply to this
email with the date, amount, and reference of your most recent payment,
and we'll look into it.

If you've changed bank account or want to confirm our payment details and
your reference you can find them on our web site:

https://london.hackspace.org.uk/members/

Alternatively if you are cancelling your membership we'd be very
interested to hear any feedback you have about why you've cancelled your
membership, or how we can improve London Hackspace - just hit reply and
let us know.

If you're still storing anything in the space, please arrange to remove
it as soon as possible, otherwise we will have to dispose of it to free
up space for other members to use.

Thanks,

The London Hackspace trustees
[email protected]

0 comments on commit b3f3519

Please sign in to comment.