Class: RailsAuditLog::PruneAuditLogJob

Inherits:
ApplicationJob
  • Object
show all
Defined in:
app/jobs/rails_audit_log/prune_audit_log_job.rb

Overview

Background job that prunes AuditLogEntry records for every audited model that has a configured retention policy.

Enqueue on a recurring schedule via your job backend (Solid Queue, Sidekiq, GoodJob, etc.):

RailsAuditLog::PruneAuditLogJob.perform_later

The job iterates over every item_type present in audit_log_entries, resolves the effective retention_period / version_limit for that model, and deletes entries that exceed either constraint. Pruning is always scoped to one item_type at a time so models do not interfere with each other.

Instance Method Summary collapse

Instance Method Details

#performObject



15
16
17
18
19
# File 'app/jobs/rails_audit_log/prune_audit_log_job.rb', line 15

def perform
  AuditLogEntry.distinct.pluck(:item_type).each do |item_type|
    prune_item_type(item_type)
  end
end