mirror of
https://github.com/internetee/registry.git
synced 2025-07-22 02:35:57 +02:00
Merge pull request #1926 from internetee/1912-auto-destroy-records-from-bounce-list
Implemented job and test
This commit is contained in:
commit
714d0e5530
2 changed files with 34 additions and 0 deletions
19
app/jobs/bounced_emails_cleaner_job.rb
Normal file
19
app/jobs/bounced_emails_cleaner_job.rb
Normal file
|
@ -0,0 +1,19 @@
|
|||
class BouncedEmailsCleanerJob < ApplicationJob
|
||||
queue_as :default
|
||||
|
||||
def perform
|
||||
BouncedMailAddress.find_each do |bounce|
|
||||
count = Contact.where(email: bounce.email).count
|
||||
if count.zero?
|
||||
logger.info "#{bounce.inspect} ARE DELETED!"
|
||||
bounce.destroy
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def logger
|
||||
@logger ||= Rails.logger
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue