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

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMatija Čupić <matteeyah@gmail.com>2018-09-27 20:28:24 +0300
committerMatija Čupić <matteeyah@gmail.com>2018-09-27 20:28:24 +0300
commit4de93b6a3e4eabd3eae9eb23910c6acd62649cfa (patch)
tree4291d45297f0aca1f217c0e2c5249a115177e7e2 /lib
parent6075a9323a228dfdb4aca7a99861e51c8988cc56 (diff)
Refactor external_pipelines query
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/background_migration/populate_external_pipeline_source.rb13
1 files changed, 5 insertions, 8 deletions
diff --git a/lib/gitlab/background_migration/populate_external_pipeline_source.rb b/lib/gitlab/background_migration/populate_external_pipeline_source.rb
index f635064cac5..98eb7f0b897 100644
--- a/lib/gitlab/background_migration/populate_external_pipeline_source.rb
+++ b/lib/gitlab/background_migration/populate_external_pipeline_source.rb
@@ -24,18 +24,15 @@ module Gitlab
class CommitStatus < ActiveRecord::Base
self.table_name = 'ci_builds'
self.inheritance_column = :_type_disabled
- end
-
- class Build < CommitStatus
- end
- class GenericCommitStatus < CommitStatus
+ scope :has_pipeline, -> { where('ci_builds.commit_id=ci_pipelines.id') }
+ scope :of_type, -> (type) { where('type=?', type) }
end
end
def perform(start_id, stop_id)
external_pipelines(start_id, stop_id)
- .update_all(:source, Migratable::Pipeline.sources[:external])
+ .update_all(source: Migratable::Pipeline.sources[:external])
end
private
@@ -44,8 +41,8 @@ module Gitlab
Migratable::Pipeline.where(id: (start_id..stop_id))
.where(
'EXISTS (?) AND NOT EXISTS (?)',
- Migratable::GenericCommitStatus.where("type='CommitStatus'").where('ci_builds.commit_id=ci_pipelines.id').select(1),
- Migratable::Build.where("type='Ci::Build'").where('ci_builds.commit_id=ci_pipelines.id').select(1)
+ Migratable::CommitStatus.of_type('GenericCommitStatus').has_pipeline.select(1),
+ Migratable::CommitStatus.of_type('Ci::Build').has_pipeline.select(1),
)
end
end