Class: StandardAudit::CleanupJob

Inherits:
ActiveJob::Base
  • Object
show all
Defined in:
app/jobs/standard_audit/cleanup_job.rb

Instance Method Summary collapse

Instance Method Details

#performObject



5
6
7
8
9
10
11
12
# File 'app/jobs/standard_audit/cleanup_job.rb', line 5

def perform
  days = StandardAudit.config.retention_days
  return unless days

  cutoff = days.days.ago
  deleted = StandardAudit::AuditLog.before(cutoff).in_batches(of: 10_000).delete_all
  Rails.logger.info("[StandardAudit] CleanupJob deleted #{deleted} audit logs older than #{days} days")
end