Class: MailerLog::CleanupJob

Inherits:
ApplicationJob show all
Defined in:
app/jobs/mailer_log/cleanup_job.rb

Instance Method Summary collapse

Instance Method Details

#perform ⇒ Object



7
8
9
10
11
12
13
14
# File 'app/jobs/mailer_log/cleanup_job.rb', line 7

def perform
  retention_period = MailerLog.configuration.retention_period
  cutoff_date = retention_period.ago

  deleted_count = MailerLog::Email.where('created_at < ?', cutoff_date).delete_all

  Rails.logger.info("MailerLog::CleanupJob: Deleted #{deleted_count} emails older than #{cutoff_date}")
end