added logging

This commit is contained in:
Oleg Hasjanov 2021-04-19 10:21:30 +03:00
parent 77b99b3d2e
commit 649d355972

View file

@ -4,7 +4,16 @@ class BouncedEmailsCleanerJob < ApplicationJob
def perform def perform
BouncedMailAddress.find_each do |bounce| BouncedMailAddress.find_each do |bounce|
count = Contact.where(email: bounce.email).count count = Contact.where(email: bounce.email).count
bounce.destroy if count.zero? if count.zero?
logger.info "#{bounce.inspect} ARE DELETED!"
bounce.destroy
end
end end
end end
private
def logger
@logger ||= Logger.new(Rails.root.join('log', 'deleted_bounced_mails.log'))
end
end end