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
b904cebf
Commit
b904cebf
authored
Sep 25, 2019
by
Cameron Swords
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add index to build options for fast searching
parent
d2d0df9b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
1 deletion
+27
-1
app/models/ci/build.rb
app/models/ci/build.rb
+1
-1
db/migrate/20190925054412_add_index_to_build_options.rb
db/migrate/20190925054412_add_index_to_build_options.rb
+25
-0
db/schema.rb
db/schema.rb
+1
-0
No files found.
app/models/ci/build.rb
View file @
b904cebf
...
...
@@ -128,7 +128,7 @@ module Ci
scope
:with_stale_live_trace
,
->
{
with_live_trace
.
finished_before
(
12
.
hours
.
ago
)
}
scope
:finished_before
,
->
(
date
)
{
finished
.
where
(
'finished_at < ?'
,
date
)
}
scope
:with_secure_report_legacy
,
->
(
job_type
)
{
where
(
'options like :job_type'
,
job_type:
"%
#{
job_type
}
%"
)
}
scope
:with_secure_report_legacy
,
->
(
job_type
)
{
where
(
'options like :job_type'
,
job_type:
"%
:artifacts:%:reports:%:
#{
job_type
}
:
%"
)
}
scope
:with_secure_reports
,
->
(
job_types
)
do
joins
(
:metadata
).
where
(
"ci_builds_metadata.config_options -> 'artifacts' -> 'reports' ?| array[:job_types]"
,
job_types:
job_types
)
...
...
db/migrate/20190925054412_add_index_to_build_options.rb
0 → 100644
View file @
b904cebf
# frozen_string_literal: true
class
AddIndexToBuildOptions
<
ActiveRecord
::
Migration
[
5.2
]
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
INDEX_NAME
=
'index_build_on_options'
disable_ddl_transaction!
def
up
add_concurrent_index
:ci_builds
,
:options
,
name:
INDEX_NAME
,
using: :gist
,
opclass: :gist_trgm_ops
,
where:
"options like '%:artifacts:%:reports:%:sast:%'"
\
" or options like '%:artifacts:%:reports:%:dast:%'"
\
" or options like '%:artifacts:%:reports:%:dependency_scanning:%'"
\
" or options like '%:artifacts:%:reports:%:container_scanning:%'"
end
def
down
remove_concurrent_index_by_name
:ci_builds
,
INDEX_NAME
end
end
db/schema.rb
View file @
b904cebf
...
...
@@ -644,6 +644,7 @@ ActiveRecord::Schema.define(version: 2019_10_04_134055) do
t
.
index
[
"commit_id"
,
"type"
,
"name"
,
"ref"
],
name:
"index_ci_builds_on_commit_id_and_type_and_name_and_ref"
t
.
index
[
"commit_id"
,
"type"
,
"ref"
],
name:
"index_ci_builds_on_commit_id_and_type_and_ref"
t
.
index
[
"name"
],
name:
"index_ci_builds_on_name_for_security_products_values"
,
where:
"((name)::text = ANY (ARRAY[('container_scanning'::character varying)::text, ('dast'::character varying)::text, ('dependency_scanning'::character varying)::text, ('license_management'::character varying)::text, ('sast'::character varying)::text]))"
t
.
index
[
"options"
],
name:
"index_build_on_options"
,
opclass: :gist_trgm_ops
,
where:
"((options ~~ '%:artifacts:%:reports:%:sast:%'::text) OR (options ~~ '%:artifacts:%:reports:%:dast:%'::text) OR (options ~~ '%:artifacts:%:reports:%:dependency_scanning:%'::text) OR (options ~~ '%:artifacts:%:reports:%:container_scanning:%'::text))"
,
using: :gist
t
.
index
[
"project_id"
,
"id"
],
name:
"index_ci_builds_on_project_id_and_id"
t
.
index
[
"project_id"
,
"status"
],
name:
"index_ci_builds_project_id_and_status_for_live_jobs_partial2"
,
where:
"(((type)::text = 'Ci::Build'::text) AND ((status)::text = ANY (ARRAY[('running'::character varying)::text, ('pending'::character varying)::text, ('created'::character varying)::text])))"
t
.
index
[
"project_id"
],
name:
"index_ci_builds_on_project_id_for_successfull_pages_deploy"
,
where:
"(((type)::text = 'GenericCommitStatus'::text) AND ((stage)::text = 'deploy'::text) AND ((name)::text = 'pages:deploy'::text) AND ((status)::text = 'success'::text))"
...
...
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