scheduled_statuses_scheduler.rb 420 Bytes
Newer Older
Rob Colbert's avatar
Rob Colbert committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
# frozen_string_literal: true

class Scheduler::ScheduledStatusesScheduler
  include Sidekiq::Worker

  def perform
    due_statuses.find_each do |scheduled_status|
      PublishScheduledStatusWorker.perform_at(scheduled_status.scheduled_at, scheduled_status.id)
    end
  end

  private

  def due_statuses
    ScheduledStatus.where('scheduled_at <= ?', Time.now.utc + PostStatusService::MIN_SCHEDULE_OFFSET)
  end
end