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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
0082d9f3
Commit
0082d9f3
authored
Sep 02, 2020
by
Mehmet Emin INAC
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use `NOT EXISTS` instead of `NOT IN`
parent
bd93f764
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
10 deletions
+18
-10
ee/lib/ee/gitlab/background_migration/populate_resolved_on_default_branch_column.rb
...d_migration/populate_resolved_on_default_branch_column.rb
+18
-10
No files found.
ee/lib/ee/gitlab/background_migration/populate_resolved_on_default_branch_column.rb
View file @
0082d9f3
...
...
@@ -199,11 +199,14 @@ module EE
class
Vulnerability
<
ActiveRecord
::
Base
include
EachBatch
scope
:not_found_in_pipeline_id
,
->
(
pipeline_id
)
{
where
.
not
(
id:
found_in_pipeline
(
pipeline_id
))
}
scope
:found_in_pipeline
,
->
(
pipeline_id
)
do
joins
(
<<~
SQL
)
INNER JOIN vulnerability_occurrences vo ON vo.vulnerability_id = vulnerabilities.id
INNER JOIN vulnerability_occurrence_pipelines vop ON vop.occurrence_id = vo.id AND vop.pipeline_id =
#{
pipeline_id
}
scope
:not_found_in_pipeline_id
,
->
(
pipeline_id
)
do
where
(
<<~
SQL
)
NOT EXISTS (
SELECT 1
FROM vulnerability_occurrences vo
INNER JOIN vulnerability_occurrence_pipelines vop ON vop.occurrence_id = vo.id
WHERE vo.vulnerability_id = vulnerabilities.id AND vop.pipeline_id =
#{
pipeline_id
}
)
SQL
end
end
...
...
@@ -265,6 +268,7 @@ module EE
def
initialize
(
project_id
)
self
.
project_id
=
project_id
self
.
updated_count
=
0
end
def
perform
...
...
@@ -274,20 +278,24 @@ module EE
log_error
(
e
)
end
private
attr_accessor
:project_id
,
:updated_count
attr_accessor
:project_id
private
def
update_vulnerabilities
@updated_count
||=
project
.
resolved_vulnerabilities
.
update_all
(
resolved_on_default_branch:
true
)
return
if
project
.
resolved_vulnerabilities
.
none?
project
.
vulnerabilities
.
each_batch
do
|
relation
|
self
.
updated_count
+=
relation
.
merge
(
project
.
resolved_vulnerabilities
)
.
update_all
(
resolved_on_default_branch:
true
)
end
end
def
log_info
::
Gitlab
::
BackgroundMigration
::
Logger
.
info
(
migrator:
'PopulateResolvedOnDefaultBranchColumnForProject'
,
message:
'Project migrated'
,
updated_count:
@
updated_count
,
updated_count:
updated_count
,
project_id:
project_id
)
end
...
...
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