From 9c9a3c61117d0171129834cb7d5cfcc219143ccd Mon Sep 17 00:00:00 2001 From: Paul Arterburn Date: Tue, 28 May 2024 20:47:51 -0600 Subject: [PATCH] Don't background send --- app/jobs/entry_job.rb | 16 ---------------- lib/tasks/entry.rake | 4 ++-- 2 files changed, 2 insertions(+), 18 deletions(-) delete mode 100644 app/jobs/entry_job.rb diff --git a/app/jobs/entry_job.rb b/app/jobs/entry_job.rb deleted file mode 100644 index 8c902880..00000000 --- a/app/jobs/entry_job.rb +++ /dev/null @@ -1,16 +0,0 @@ -class EntryJob < ActiveJob::Base - queue_as :default - - retry_on RestClient::Unauthorized, wait: 5.minutes, attempts: 3 - - def perform(user_id, random_inspiration_id, sent_in_hour) - user = User.find(user_id) - random_inspiration = Inspiration.find(random_inspiration_id) - EntryMailer.send_entry(user, random_inspiration).deliver_now - rescue StandardError => e - Sentry.set_user(id: user.id, email: user.email) - Sentry.set_tags(plan: user.plan) - Sentry.capture_exception(e, extra: { sent_in_hour: sent_in_hour }) - raise - end -end diff --git a/lib/tasks/entry.rake b/lib/tasks/entry.rake index d3af2132..6e5be82a 100644 --- a/lib/tasks/entry.rake +++ b/lib/tasks/entry.rake @@ -5,7 +5,7 @@ namespace :entry do # rake entry:send_entries_test task :send_entries_test => :environment do user = User.where(:email=>"admin@dabble.ex").first - EntryJob.perform_later(user.id, Inspiration.random.id, 0) + EntryMailer.send_entry(user, Inspiration.random).deliver_now end # TRIGGERED MANUALLY @@ -186,7 +186,7 @@ namespace :entry do if user.is_free? && user.emails_sent > 6 && user.entries.count == 0 && ENV['FREE_WEEK'] != 'true' user.update_columns(frequency: [], previous_frequency: user.frequency) elsif user.is_pro? || (user.is_free? && Time.now.strftime("%U").to_i % 2 == 0) || ENV['FREE_WEEK'] == 'true' # Every other week for free users - EntryJob.perform_later(user.id, random_inspiration.id, sent_in_hour) + EntryMailer.send_entry(user, random_inspiration).deliver_now sent_in_hour += 1 end rescue => error