summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-04-06 12:10:44 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-04-06 12:10:44 +0000
commitba174c982f40d71a87fd511b091753807174f7e7 (patch)
treeb89d55c715288f2c2f76724c1b7ff4a6ebf90154 /app/models
parenteaea945e0355826c58c3dcf887496ea91064f85c (diff)
downloadgitlab-ce-ba174c982f40d71a87fd511b091753807174f7e7.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models')
-rw-r--r--app/models/concerns/import_state/sidekiq_job_tracker.rb23
-rw-r--r--app/models/jira_import_state.rb11
-rw-r--r--app/models/merge_request.rb2
-rw-r--r--app/models/project_import_state.rb15
4 files changed, 26 insertions, 25 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
diff --git a/app/models/jira_import_state.rb b/app/models/jira_import_state.rb
index 0c138d674ea..713feec013f 100644
--- a/app/models/jira_import_state.rb
+++ b/app/models/jira_import_state.rb
@@ -2,6 +2,7 @@
class JiraImportState < ApplicationRecord
include AfterCommitQueue
+ include ImportState::SidekiqJobTracker
self.table_name = 'jira_imports'
@@ -66,14 +67,4 @@ class JiraImportState < ApplicationRecord
def in_progress?
scheduled? || started?
end
-
- 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
diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb
index 7934b0f8f59..2edb1a45100 100644
--- a/app/models/merge_request.rb
+++ b/app/models/merge_request.rb
@@ -1290,7 +1290,7 @@ class MergeRequest < ApplicationRecord
variables.append(key: 'CI_MERGE_REQUEST_PROJECT_URL', value: project.web_url)
variables.append(key: 'CI_MERGE_REQUEST_TARGET_BRANCH_NAME', value: target_branch.to_s)
variables.append(key: 'CI_MERGE_REQUEST_TITLE', value: title)
- variables.append(key: 'CI_MERGE_REQUEST_ASSIGNEES', value: assignee_username_list) if assignees.any?
+ variables.append(key: 'CI_MERGE_REQUEST_ASSIGNEES', value: assignee_username_list) if assignees.present?
variables.append(key: 'CI_MERGE_REQUEST_MILESTONE', value: milestone.title) if milestone
variables.append(key: 'CI_MERGE_REQUEST_LABELS', value: label_names.join(',')) if labels.present?
variables.concat(source_project_variables)
diff --git a/app/models/project_import_state.rb b/app/models/project_import_state.rb
index cdb034e58fa..52fd23aefd5 100644
--- a/app/models/project_import_state.rb
+++ b/app/models/project_import_state.rb
@@ -2,6 +2,7 @@
class ProjectImportState < ApplicationRecord
include AfterCommitQueue
+ include ImportState::SidekiqJobTracker
self.table_name = "project_mirror_data"
@@ -88,20 +89,6 @@ class ProjectImportState < ApplicationRecord
# import? does SQL work so only run it if it looks like there's an import running
status == 'started' && project.import?
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
-
- def self.jid_by(project_id:, status:)
- select(:jid).with_status(status).find_by(project_id: project_id)
- end
end
ProjectImportState.prepend_if_ee('EE::ProjectImportState')