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
d0e2cd52
Commit
d0e2cd52
authored
Oct 06, 2021
by
Vitali Tatarintev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add limit to recent_diff_head_shas as an argument
parent
06c97c26
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
5 additions
and
10 deletions
+5
-10
app/finders/ci/pipelines_for_merge_request_finder.rb
app/finders/ci/pipelines_for_merge_request_finder.rb
+2
-7
app/models/merge_request.rb
app/models/merge_request.rb
+2
-2
app/models/merge_request_diff.rb
app/models/merge_request_diff.rb
+1
-1
No files found.
app/finders/ci/pipelines_for_merge_request_finder.rb
View file @
d0e2cd52
...
@@ -14,7 +14,7 @@ module Ci
...
@@ -14,7 +14,7 @@ module Ci
attr_reader
:merge_request
,
:current_user
attr_reader
:merge_request
,
:current_user
delegate
:
merge_request_diff
s
,
:commit_shas
,
:target_project
,
:source_project
,
:source_branch
,
to: :merge_request
delegate
:
recent_diff_head_sha
s
,
:commit_shas
,
:target_project
,
:source_project
,
:source_branch
,
to: :merge_request
# Fetch all pipelines that the user can read.
# Fetch all pipelines that the user can read.
def
execute
def
execute
...
@@ -84,7 +84,7 @@ module Ci
...
@@ -84,7 +84,7 @@ module Ci
def
all_pipelines_for_merge_request
def
all_pipelines_for_merge_request
if
Feature
.
enabled?
(
:decomposed_ci_query_in_pipelines_for_merge_request_finder
,
source_project
,
default_enabled: :yaml
)
if
Feature
.
enabled?
(
:decomposed_ci_query_in_pipelines_for_merge_request_finder
,
source_project
,
default_enabled: :yaml
)
pipelines_for_merge_request
=
triggered_by_merge_request
pipelines_for_merge_request
=
triggered_by_merge_request
pipelines_for_branch
=
triggered_for_branch
.
for_sha
(
recent_diff_head_shas
)
pipelines_for_branch
=
triggered_for_branch
.
for_sha
(
recent_diff_head_shas
(
COMMITS_LIMIT
)
)
Ci
::
Pipeline
.
from_union
([
pipelines_for_merge_request
,
pipelines_for_branch
])
Ci
::
Pipeline
.
from_union
([
pipelines_for_merge_request
,
pipelines_for_branch
])
else
else
...
@@ -92,11 +92,6 @@ module Ci
...
@@ -92,11 +92,6 @@ module Ci
end
end
end
end
def
recent_diff_head_shas
# We're limiting the number of commits' SHAs to 100 since they are used in a WHERE clause of a query
merge_request_diffs
.
recent
.
limit
(
COMMITS_LIMIT
).
pluck
(
:head_commit_sha
).
uniq
# rubocop: disable CodeReuse/ActiveRecord
end
# NOTE: this method returns only parent merge request pipelines.
# NOTE: this method returns only parent merge request pipelines.
# Child merge request pipelines have a different source.
# Child merge request pipelines have a different source.
def
triggered_by_merge_request
def
triggered_by_merge_request
...
...
app/models/merge_request.rb
View file @
d0e2cd52
...
@@ -1658,8 +1658,8 @@ class MergeRequest < ApplicationRecord
...
@@ -1658,8 +1658,8 @@ class MergeRequest < ApplicationRecord
service_class
.
new
(
project
,
current_user
,
id:
id
,
report_type:
report_type
).
execute
(
comparison_base_pipeline
(
identifier
),
actual_head_pipeline
)
service_class
.
new
(
project
,
current_user
,
id:
id
,
report_type:
report_type
).
execute
(
comparison_base_pipeline
(
identifier
),
actual_head_pipeline
)
end
end
def
recent_diff_head_shas
def
recent_diff_head_shas
(
limit
=
100
)
merge_request_diffs
.
recent
.
pluck
(
:head_commit_sha
)
merge_request_diffs
.
recent
(
limit
)
.
pluck
(
:head_commit_sha
)
end
end
def
all_commits
def
all_commits
...
...
app/models/merge_request_diff.rb
View file @
d0e2cd52
...
@@ -66,7 +66,7 @@ class MergeRequestDiff < ApplicationRecord
...
@@ -66,7 +66,7 @@ class MergeRequestDiff < ApplicationRecord
joins
(
:merge_request
).
where
(
merge_requests:
{
target_project_id:
project_id
})
joins
(
:merge_request
).
where
(
merge_requests:
{
target_project_id:
project_id
})
end
end
scope
:recent
,
->
{
order
(
id: :desc
).
limit
(
100
)
}
scope
:recent
,
->
(
limit
=
100
)
{
order
(
id: :desc
).
limit
(
limit
)
}
scope
:files_in_database
,
->
do
scope
:files_in_database
,
->
do
where
(
stored_externally:
[
false
,
nil
]).
where
(
arel_table
[
:files_count
].
gt
(
0
))
where
(
stored_externally:
[
false
,
nil
]).
where
(
arel_table
[
:files_count
].
gt
(
0
))
...
...
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