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.45 app/workers/workarea/verify_scheduled_releases.rb
workarea-core-3.4.44 app/workers/workarea/verify_scheduled_releases.rb
workarea-core-3.4.43 app/workers/workarea/verify_scheduled_releases.rb
workarea-core-3.4.42 app/workers/workarea/verify_scheduled_releases.rb
workarea-core-3.4.41 app/workers/workarea/verify_scheduled_releases.rb
workarea-core-3.4.40 app/workers/workarea/verify_scheduled_releases.rb
workarea-core-3.4.39 app/workers/workarea/verify_scheduled_releases.rb
workarea-core-3.4.38 app/workers/workarea/verify_scheduled_releases.rb
workarea-core-3.4.37 app/workers/workarea/verify_scheduled_releases.rb
workarea-core-3.4.36 app/workers/workarea/verify_scheduled_releases.rb
workarea-core-3.4.35 app/workers/workarea/verify_scheduled_releases.rb
workarea-core-3.4.34 app/workers/workarea/verify_scheduled_releases.rb
workarea-core-3.4.33 app/workers/workarea/verify_scheduled_releases.rb
workarea-core-3.4.32 app/workers/workarea/verify_scheduled_releases.rb
workarea-core-3.4.31 app/workers/workarea/verify_scheduled_releases.rb
workarea-core-3.4.30 app/workers/workarea/verify_scheduled_releases.rb
workarea-core-3.4.29 app/workers/workarea/verify_scheduled_releases.rb
workarea-core-3.4.28 app/workers/workarea/verify_scheduled_releases.rb
workarea-core-3.4.27 app/workers/workarea/verify_scheduled_releases.rb
workarea-core-3.4.26 app/workers/workarea/verify_scheduled_releases.rb