diff --git a/app/jobs/application_job.rb b/app/jobs/application_job.rb index 155893c6e..1771693ea 100644 --- a/app/jobs/application_job.rb +++ b/app/jobs/application_job.rb @@ -10,7 +10,6 @@ def run(*) log 'running' if duplicate_job_queued? - log 'already queued', :warn raise DuplicateJobError, 'already queued' elsif block_given? yield @@ -31,7 +30,7 @@ def duplicate_job_queued? def handle_error(error) log "failed with '#{error.message}'", :warn case error - when DuplicateJobError then expire + when StandardError then expire end end diff --git a/app/jobs/test_bulk_mail_job.rb b/app/jobs/test_bulk_mail_job.rb index a66e6be8e..a401e7531 100644 --- a/app/jobs/test_bulk_mail_job.rb +++ b/app/jobs/test_bulk_mail_job.rb @@ -5,11 +5,19 @@ def run super do self.class.recipients.find_each do |recipient| - recipient.send_devise_notification(:bulk_test) + recipient.test_email # TODO: user record log of mail activity? # recipient.update!(notify_log:) + # where("notify_callback -> 'template_id' ?", template_id) end end + + private + + # @return [String] + def template_id + NotifyMailer::TEMPLATE_IDS[:bulk_test] + end end end diff --git a/app/models/user.rb b/app/models/user.rb index b1673d305..49bbbd3a9 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -161,12 +161,6 @@ def test_user? email_delivered.where('notify_callback @> ?', { template_id: template_id }.to_json) } - # scope :new_module_delivered, -> { - # # where("properties -> 'training_module_id' ?| array[:values]", values: mod_names) - # where("notify_callback -> 'template_id' ?", NotifyMailer::TEMPLATE_IDS[:new_module]) - # # '2352b6ce-a098-47f0-870a-286308b9798f' - # } - # data scope :dashboard, -> { not_closed } scope :month_old_confirmation, -> { where(confirmed_at: 4.weeks.ago.beginning_of_day..4.weeks.ago.end_of_day) } @@ -233,6 +227,10 @@ def active_modules end end + def test_email + send_devise_notification(:bulk_test) unless Rails.application.live? + end + def send_account_closed_notification send_devise_notification(:account_closed) end