Class: Cron::TrimAuditLogs

Inherits:
TrimCollection show all
Defined in:
lib/app/jobs/cron/trim_audit_logs.rb

Overview

Clean up Audit Logs that have not been updated in 90 days

Instance Method Summary collapse

Methods inherited from TrimCollection

#allowed_time_for_item, #perform, #trim_item

Methods inherited from Job

cron_tab_entry, #send_support_email

Methods inherited from ApplicationJob

valid_environment?, valid_environments

Methods included from App47Logger

clean_params, #clean_params, delete_parameter_keys, #log_controller_error, log_debug, #log_debug, log_error, #log_error, log_exception, #log_message, log_message, #log_warn, log_warn, mask_parameter_keys, #update_flash_messages

Instance Method Details

#allowed_timeObject

Allowed time the amount of time allowed to exists before deleting



30
31
32
# File 'lib/app/jobs/cron/trim_audit_logs.rb', line 30

def allowed_time
  90.days.ago
end

#archive?(item) ⇒ Boolean

Check which audit logs we wanted deleted

Should be older than 90 days and either not a user model audit log or the model associated with the UserModelAuditLog has been deleted

Returns:

  • (Boolean)


21
22
23
24
25
# File 'lib/app/jobs/cron/trim_audit_logs.rb', line 21

def archive?(item)
  super && (!item.is_a?(UserModelAuditLog) || item.model.blank?)
rescue StandardError
  super
end

#collectionObject

Fetch each Audit Log and delete it if hasn’t been updated in 90 days



11
12
13
# File 'lib/app/jobs/cron/trim_audit_logs.rb', line 11

def collection
  AuditLog.all
end