Sha256: 5ac86a63d432b78b81ecff74a928e0ecf2dda5e5e15a73c92ec3dde93650019a

Contents?: true

Size: 1 KB

Versions: 34

Compression:

Stored size: 1 KB

Contents

module Workarea
  # Verify that jobs for publishing and undoing releases do not get removed
  # unintentionally from sidekiq and prevent the release from updating at the
  # expected time. If any are found missing, add a new job.
  # Runs hourly by default, 5 minutes before each hour.
  #
  class VerifyScheduledReleases
    include Sidekiq::Worker

    def perform(*)
      # Both PublishRelease and UndoRelease use the default queue,
      # so only look there for scheduled release jobs
      job_ids = Sidekiq::Queue.new.map { |job| job.jid }
      now = Time.current

      Release.all.each do |release|
        if release.scheduled? &&
           release.publish_at > now &&
           !job_ids.include?(release.publish_job_id)

          release.set_publish_job
          release.save!
        end

        if release.undo_at.present? &&
           release.undo_at > now &&
           !job_ids.include?(release.undo_job_id)

          release.set_undo_job
          release.save!
        end
      end
    end
  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
workarea-core-3.4.25 app/workers/workarea/verify_scheduled_releases.rb
workarea-core-3.4.24 app/workers/workarea/verify_scheduled_releases.rb
workarea-core-3.4.23 app/workers/workarea/verify_scheduled_releases.rb
workarea-core-3.4.22 app/workers/workarea/verify_scheduled_releases.rb
workarea-core-3.4.21 app/workers/workarea/verify_scheduled_releases.rb
workarea-core-3.4.20 app/workers/workarea/verify_scheduled_releases.rb
workarea-core-3.4.19 app/workers/workarea/verify_scheduled_releases.rb
workarea-core-3.4.18 app/workers/workarea/verify_scheduled_releases.rb
workarea-core-3.4.17 app/workers/workarea/verify_scheduled_releases.rb
workarea-core-3.4.16 app/workers/workarea/verify_scheduled_releases.rb
workarea-core-3.4.15 app/workers/workarea/verify_scheduled_releases.rb
workarea-core-3.4.14 app/workers/workarea/verify_scheduled_releases.rb
workarea-core-3.4.13 app/workers/workarea/verify_scheduled_releases.rb
workarea-core-3.4.12 app/workers/workarea/verify_scheduled_releases.rb