Class: ActionTrace::PurgeActivityLogJob

Inherits:
ApplicationJob
  • Object
show all
Defined in:
app/jobs/action_trace/purge_activity_log_job.rb

Instance Method Summary collapse

Instance Method Details

#performObject



7
8
9
10
11
12
13
14
15
# File 'app/jobs/action_trace/purge_activity_log_job.rb', line 7

def perform
  threshold = ActionTrace.configuration.log_retention_period.ago

  act_count = PublicActivity::Activity.where(created_at: ...threshold).delete_all
  evt_count = Ahoy::Event.where(time: ...threshold).delete_all
  vst_count = Ahoy::Visit.where(started_at: ...threshold).delete_all

  Rails.logger.info "Activity log: Removed #{act_count} PublicActivities, #{evt_count} AhoyEvents, #{vst_count} AhoyVisits."
end