BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
1a3edcec
Commit
1a3edcec
authored
Jul 07, 2017
by
Douwe Maan
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'speed-up-merge-request-all-commits-shas' into 'master'
Speed up `all_commit_shas` for new merge requests See merge request !12706
parents
4ccdb83a
4c0864fd
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
2 deletions
+9
-2
merge_request.rb
app/models/merge_request.rb
+4
-1
speed-up-merge-request-all-commits-shas.yml
...gs/unreleased/speed-up-merge-request-all-commits-shas.yml
+4
-0
merge_request_spec.rb
spec/models/merge_request_spec.rb
+1
-1
No files found.
app/models/merge_request.rb
View file @
1a3edcec
...
...
@@ -849,7 +849,10 @@ class MergeRequest < ActiveRecord::Base
#
def
all_commit_shas
if
persisted?
merge_request_diffs
.
preload
(
:merge_request_diff_commits
).
flat_map
(
&
:commit_shas
).
uniq
column_shas
=
MergeRequestDiffCommit
.
where
(
merge_request_diff:
merge_request_diffs
).
pluck
(
'DISTINCT(sha)'
)
serialised_shas
=
merge_request_diffs
.
where
.
not
(
st_commits:
nil
).
flat_map
(
&
:commit_shas
)
(
column_shas
+
serialised_shas
).
uniq
elsif
compare_commits
compare_commits
.
to_a
.
reverse
.
map
(
&
:id
)
else
...
...
changelogs/unreleased/speed-up-merge-request-all-commits-shas.yml
0 → 100644
View file @
1a3edcec
---
title
:
Make loading new merge requests (those created after the 9.4 upgrade) faster
merge_request
:
author
:
spec/models/merge_request_spec.rb
View file @
1a3edcec
...
...
@@ -803,7 +803,7 @@ describe MergeRequest, models: true do
shared_examples
'returning all SHA'
do
it
'returns all SHA from all merge_request_diffs'
do
expect
(
subject
.
merge_request_diffs
.
size
).
to
eq
(
2
)
expect
(
subject
.
all_commit_shas
).
to
eq
(
all_commit_shas
)
expect
(
subject
.
all_commit_shas
).
to
match_array
(
all_commit_shas
)
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