Skip to content

Instantly share code, notes, and snippets.

@PerezIgnacio
Created January 31, 2020 14:03
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 PerezIgnacio/01a45bb385afb84b1a8e792360a30696 to your computer and use it in GitHub Desktop.
Save PerezIgnacio/01a45bb385afb84b1a8e792360a30696 to your computer and use it in GitHub Desktop.
Example using UsersQuery
task send_emails_notifications: :environment do
def send_email_to_users_without_recent_visits
users_without_recent_views = UsersQuery.new.without_recent_views
UsersQuery.new(users_without_recent_views).subscribed.find_each do |user|
SendNewProductsRecommendationsJob.perform_later(user)
end
end
def send_similar_purchases_emails_to_users
UsersQuery.new.for_notifications_of_similar_purchases.find_each do |user|
SendSimilarPurchasesRecomendationsJob.perform_later(user)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment