Class: Joblin::BackgroundTask::RetentionPolicy::BackgroundTaskCleaner

Inherits:
ActiveJob::Base
  • Object
show all
Defined in:
app/models/joblin/background_task/retention_policy.rb

Instance Method Summary collapse

Instance Method Details

#performObject



17
18
19
20
21
22
23
24
25
26
# File 'app/models/joblin/background_task/retention_policy.rb', line 17

def perform
  types = BackgroundTask.distinct.pluck(:type)
  types.each do |type|
    type = type.constantize
    rp = type.record_retention
    next unless rp

    type.where("created_at < ?", rp.ago).destroy_all
  end
end