Skip to content

Instantly share code, notes, and snippets.

@spif
Created December 23, 2010 20:39
Show Gist options
  • Save spif/753517 to your computer and use it in GitHub Desktop.
Save spif/753517 to your computer and use it in GitHub Desktop.
# this script can be run as often as desired, just don't do it concurrently
free = Plan.free
User.find(:all, :conditions => ["plan_id = ? AND contact_count BETWEEN ? AND ?",free.id, free.soft_max_contact, free.hard_max_contact]).each do |u|
next if EmailBlacklist.banned?(u.username)
last_email = u.email_logs.detect{|l| l.name == "soft_limit_breached"}
next if !last_email.nil? && last_email.created_at > Time.now - 7.days
Mailer.deliver_soft_limit_breached(u)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment