diff options
author | Tiago Botelho <tiagonbotelho@hotmail.com> | 2018-11-27 12:41:27 +0300 |
---|---|---|
committer | Tiago Botelho <tiagonbotelho@hotmail.com> | 2018-11-27 15:58:13 +0300 |
commit | 4bd8a427d4e8127f1badc7365b35702472918956 (patch) | |
tree | d8e64bd046f35b64ad6f88bdd062e1e8f364c327 /app/models/project_import_state.rb | |
parent | d3f033d69cec33e8058ee9f029718882990175b0 (diff) |
Removes all the irrelevant import related code and columns
Clears the import related columns and code from the Project
model over to the ProjectImportState model
Diffstat (limited to 'app/models/project_import_state.rb')
-rw-r--r-- | app/models/project_import_state.rb | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/app/models/project_import_state.rb b/app/models/project_import_state.rb index 7126bb66d80..c80e612053c 100644 --- a/app/models/project_import_state.rb +++ b/app/models/project_import_state.rb @@ -69,4 +69,33 @@ class ProjectImportState < ActiveRecord::Base ensure @errors = original_errors end + + alias_method :no_import?, :none? + + def in_progress? + started? || scheduled? + end + + def started? + # import? does SQL work so only run it if it looks like there's an import running + status == 'started' && project.import? + end + + def remove_jid + return unless jid + + Gitlab::SidekiqStatus.unset(jid) + + update_column(:jid, nil) + end + + # 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 end |