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
0f936592
Commit
0f936592
authored
Feb 20, 2020
by
Igor Drozdov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Scope pipelines to a project while loading artifacts
This commit improves performance of a query
parent
fd486c93
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
7 deletions
+8
-7
app/models/ci/job_artifact.rb
app/models/ci/job_artifact.rb
+1
-1
lib/api/lsif_data.rb
lib/api/lsif_data.rb
+2
-2
spec/models/ci/job_artifact_spec.rb
spec/models/ci/job_artifact_spec.rb
+5
-4
No files found.
app/models/ci/job_artifact.rb
View file @
0f936592
...
...
@@ -74,7 +74,7 @@ module Ci
scope
:with_files_stored_locally
,
->
{
where
(
file_store:
[
nil
,
::
JobArtifactUploader
::
Store
::
LOCAL
])
}
scope
:with_files_stored_remotely
,
->
{
where
(
file_store:
::
JobArtifactUploader
::
Store
::
REMOTE
)
}
scope
:for_sha
,
->
(
sha
)
{
joins
(
job: :pipeline
).
where
(
ci_pipelines:
{
sha:
sha
})
}
scope
:for_sha
,
->
(
sha
,
project_id
)
{
joins
(
job: :pipeline
).
where
(
ci_pipelines:
{
sha:
sha
,
project_id:
project_id
})
}
scope
:with_file_types
,
->
(
file_types
)
do
types
=
self
.
file_types
.
select
{
|
file_type
|
file_types
.
include?
(
file_type
)
}.
values
...
...
lib/api/lsif_data.rb
View file @
0f936592
...
...
@@ -21,9 +21,9 @@ module API
authorize!
:download_code
,
user_project
artifact
=
@project
.
job_artifacts
Ci
::
JobArtifact
.
with_file_types
([
'lsif'
])
.
for_sha
(
params
[
:commit_id
])
.
for_sha
(
params
[
:commit_id
]
,
@project
.
id
)
.
last
not_found!
unless
artifact
...
...
spec/models/ci/job_artifact_spec.rb
View file @
0f936592
...
...
@@ -113,13 +113,14 @@ describe Ci::JobArtifact do
describe
'.for_sha'
do
it
'returns job artifacts for a given pipeline sha'
do
first_pipeline
=
create
(
:ci_pipeline
)
second_pipeline
=
create
(
:ci_pipeline
,
sha:
Digest
::
SHA1
.
hexdigest
(
SecureRandom
.
hex
))
project
=
create
(
:project
)
first_pipeline
=
create
(
:ci_pipeline
,
project:
project
)
second_pipeline
=
create
(
:ci_pipeline
,
project:
project
,
sha:
Digest
::
SHA1
.
hexdigest
(
SecureRandom
.
hex
))
first_artifact
=
create
(
:ci_job_artifact
,
job:
create
(
:ci_build
,
pipeline:
first_pipeline
))
second_artifact
=
create
(
:ci_job_artifact
,
job:
create
(
:ci_build
,
pipeline:
second_pipeline
))
expect
(
described_class
.
for_sha
(
first_pipeline
.
sha
)).
to
eq
([
first_artifact
])
expect
(
described_class
.
for_sha
(
second_pipeline
.
sha
)).
to
eq
([
second_artifact
])
expect
(
described_class
.
for_sha
(
first_pipeline
.
sha
,
project
.
id
)).
to
eq
([
first_artifact
])
expect
(
described_class
.
for_sha
(
second_pipeline
.
sha
,
project
.
id
)).
to
eq
([
second_artifact
])
end
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