Skip to content

Instantly share code, notes, and snippets.

@stevenabrooks
Created June 17, 2014 15:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stevenabrooks/e25d841f0d29f74d99ff to your computer and use it in GitHub Desktop.
Save stevenabrooks/e25d841f0d29f74d99ff to your computer and use it in GitHub Desktop.
def self.send_all_hourly_notifications
sql_condition = <<eos
folders.discarded = 0
and users.email_updates = 1
and users.email not in (select email from email_blacklist)
and users.invalid_email != 1
and folder_members.frequency = 'hourly'
and folder_members.email_updates = 1
and folder_members.discarded = 0
eos
Folder.find(:all, :conditions => sql_condition, :joins => "folders, users, folder_members").each do |folder|
folder.batch_email_notifications(:period => :hourly)
Emails::Folders.deliver_batches if Emails::Folders.current_batch_size > 100
end
Emails::Folders.deliver_batches
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment