diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-06 15:10:44 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-06 15:10:44 +0300 |
commit | ba174c982f40d71a87fd511b091753807174f7e7 (patch) | |
tree | b89d55c715288f2c2f76724c1b7ff4a6ebf90154 /app/models/concerns/import_state | |
parent | eaea945e0355826c58c3dcf887496ea91064f85c (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models/concerns/import_state')
-rw-r--r-- | app/models/concerns/import_state/sidekiq_job_tracker.rb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/app/models/concerns/import_state/sidekiq_job_tracker.rb b/app/models/concerns/import_state/sidekiq_job_tracker.rb new file mode 100644 index 00000000000..6bb07b7c06a --- /dev/null +++ b/app/models/concerns/import_state/sidekiq_job_tracker.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +module ImportState + module SidekiqJobTracker + extend ActiveSupport::Concern + + included do + # Refreshes the expiration time of the associated import job ID. + # + # This method can be used by asynchronous importers to refresh the status, + # preventing the StuckImportJobsWorker from marking the import as failed. + def refresh_jid_expiration + return unless jid + + Gitlab::SidekiqStatus.set(jid, StuckImportJobsWorker::IMPORT_JOBS_EXPIRATION) + end + + def self.jid_by(project_id:, status:) + select(:jid).with_status(status).find_by(project_id: project_id) + end + end + end +end |