Welcome to mirror list, hosted at ThFree Co, Russian Federation.

sidekiq_job_tracker.rb « import_state « concerns « models « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: b7d0ed0f51bfd46d611a28e2d3c026e5866abd6d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# frozen_string_literal: true

module ImportState
  module SidekiqJobTracker
    extend ActiveSupport::Concern

    included do
      scope :with_jid, -> { where.not(jid: nil) }
      scope :without_jid, -> { where(jid: nil) }

      # Refreshes the expiration time of the associated import job ID.
      #
      # This method can be used by asynchronous importers to refresh the status,
      # preventing the Gitlab::Import::StuckProjectImportJobsWorker from marking the import as failed.
      def refresh_jid_expiration
        return unless jid

        Gitlab::SidekiqStatus.set(jid, Gitlab::Import::StuckImportJob::IMPORT_JOBS_EXPIRATION)
      end

      def self.jid_by(project_id:, status:)
        select(:jid).where(status: status).find_by(project_id: project_id)
      end
    end
  end
end