Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
4de93b6a
Commit
4de93b6a
authored
Sep 27, 2018
by
Matija Čupić
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor external_pipelines query
parent
6075a932
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
9 deletions
+6
-9
lib/gitlab/background_migration/populate_external_pipeline_source.rb
...background_migration/populate_external_pipeline_source.rb
+5
-8
spec/lib/gitlab/background_migration/populate_external_pipeline_source_spec.rb
...round_migration/populate_external_pipeline_source_spec.rb
+1
-1
No files found.
lib/gitlab/background_migration/populate_external_pipeline_source.rb
View file @
4de93b6a
...
@@ -24,18 +24,15 @@ module Gitlab
...
@@ -24,18 +24,15 @@ module Gitlab
class
CommitStatus
<
ActiveRecord
::
Base
class
CommitStatus
<
ActiveRecord
::
Base
self
.
table_name
=
'ci_builds'
self
.
table_name
=
'ci_builds'
self
.
inheritance_column
=
:_type_disabled
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
end
end
def
perform
(
start_id
,
stop_id
)
def
perform
(
start_id
,
stop_id
)
external_pipelines
(
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
end
private
private
...
@@ -44,8 +41,8 @@ module Gitlab
...
@@ -44,8 +41,8 @@ module Gitlab
Migratable
::
Pipeline
.
where
(
id:
(
start_id
..
stop_id
))
Migratable
::
Pipeline
.
where
(
id:
(
start_id
..
stop_id
))
.
where
(
.
where
(
'EXISTS (?) AND NOT EXISTS (?)'
,
'EXISTS (?) AND NOT EXISTS (?)'
,
Migratable
::
GenericCommitStatus
.
where
(
"type='CommitStatus'"
).
where
(
'ci_builds.commit_id=ci_pipelines.id'
)
.
select
(
1
),
Migratable
::
CommitStatus
.
of_type
(
'GenericCommitStatus'
).
has_pipeline
.
select
(
1
),
Migratable
::
Build
.
where
(
"type='Ci::Build'"
).
where
(
'ci_builds.commit_id=ci_pipelines.id'
).
select
(
1
)
Migratable
::
CommitStatus
.
of_type
(
'Ci::Build'
).
has_pipeline
.
select
(
1
),
)
)
end
end
end
end
...
...
spec/lib/gitlab/background_migration/populate_external_pipeline_source_spec.rb
View file @
4de93b6a
...
@@ -12,7 +12,7 @@ describe Gitlab::BackgroundMigration::PopulateExternalPipelineSource, :migration
...
@@ -12,7 +12,7 @@ describe Gitlab::BackgroundMigration::PopulateExternalPipelineSource, :migration
let!
(
:internal_pipeline
)
{
pipelines
.
create
(
id:
1
,
source:
described_class
::
Migratable
::
Pipeline
.
sources
[
:web
])
}
let!
(
:internal_pipeline
)
{
pipelines
.
create
(
id:
1
,
source:
described_class
::
Migratable
::
Pipeline
.
sources
[
:web
])
}
let!
(
:external_pipeline
)
{
pipelines
.
create
(
id:
2
,
source:
nil
)
}
let!
(
:external_pipeline
)
{
pipelines
.
create
(
id:
2
,
source:
nil
)
}
let!
(
:second_external_pipeline
)
{
pipelines
.
create
(
id:
3
,
source:
nil
)
}
let!
(
:second_external_pipeline
)
{
pipelines
.
create
(
id:
3
,
source:
nil
)
}
let!
(
:status
)
{
statuses
.
create
(
id:
1
,
commit_id:
2
,
type:
'CommitStatus'
)
}
let!
(
:status
)
{
statuses
.
create
(
id:
1
,
commit_id:
2
,
type:
'
Generic
CommitStatus'
)
}
let!
(
:build
)
{
builds
.
create
(
id:
2
,
commit_id:
1
,
type:
'Ci::Build'
)
}
let!
(
:build
)
{
builds
.
create
(
id:
2
,
commit_id:
1
,
type:
'Ci::Build'
)
}
subject
{
migration
.
perform
(
1
,
2
)
}
subject
{
migration
.
perform
(
1
,
2
)
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment