about summary refs log tree commit diff
path: root/app/workers/scheduler/destructing_statuses_scheduler.rb
blob: 6fc4ecccf87e036ab8ce17eb1a875c32347dfb1c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# frozen_string_literal: true

class Scheduler::DestructingStatusesScheduler
  include Sidekiq::Worker

  sidekiq_options unique: :until_executed, retry: 0

  def perform
    due_statuses.find_each do |destructing_status|
      DestructStatusWorker.perform_async(destructing_status.id)
    end
  end

  private

  def due_statuses
    DestructingStatus.where('delete_after <= ?', Time.now.utc)
  end
end