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
fc4a0cd0
Commit
fc4a0cd0
authored
Jul 31, 2018
by
Oswaldo Ferreira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Only serializes diff files found by paths query
parent
abae261b
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
5 deletions
+15
-5
app/models/merge_request_diff.rb
app/models/merge_request_diff.rb
+3
-5
changelogs/unreleased/48246-osw-load-diffs-improvement.yml
changelogs/unreleased/48246-osw-load-diffs-improvement.yml
+5
-0
spec/models/merge_request_diff_spec.rb
spec/models/merge_request_diff_spec.rb
+7
-0
No files found.
app/models/merge_request_diff.rb
View file @
fc4a0cd0
...
@@ -249,15 +249,13 @@ class MergeRequestDiff < ActiveRecord::Base
...
@@ -249,15 +249,13 @@ class MergeRequestDiff < ActiveRecord::Base
end
end
def
load_diffs
(
options
)
def
load_diffs
(
options
)
raw
=
merge_request_diff_files
.
map
(
&
:to_hash
)
collection
=
merge_request_diff_files
if
paths
=
options
[
:paths
]
if
paths
=
options
[
:paths
]
raw
=
raw
.
select
do
|
diff
|
collection
=
collection
.
where
(
'old_path IN (?) OR new_path IN (?)'
,
paths
,
paths
)
paths
.
include?
(
diff
[
:old_path
])
||
paths
.
include?
(
diff
[
:new_path
])
end
end
end
Gitlab
::
Git
::
DiffCollection
.
new
(
raw
,
options
)
Gitlab
::
Git
::
DiffCollection
.
new
(
collection
.
map
(
&
:to_hash
)
,
options
)
end
end
def
load_commits
def
load_commits
...
...
changelogs/unreleased/48246-osw-load-diffs-improvement.yml
0 → 100644
View file @
fc4a0cd0
---
title
:
Improve performance when fetching collapsed diffs and commenting in merge requests
merge_request
:
20940
author
:
type
:
performance
spec/models/merge_request_diff_spec.rb
View file @
fc4a0cd0
...
@@ -127,6 +127,13 @@ describe MergeRequestDiff do
...
@@ -127,6 +127,13 @@ describe MergeRequestDiff do
expect
(
diffs
.
map
(
&
:new_path
)).
to
contain_exactly
(
'files/ruby/popen.rb'
)
expect
(
diffs
.
map
(
&
:new_path
)).
to
contain_exactly
(
'files/ruby/popen.rb'
)
end
end
it
'only serializes diff files found by query'
do
expect
(
diff_with_commits
.
merge_request_diff_files
.
count
).
to
be
>
10
expect_any_instance_of
(
MergeRequestDiffFile
).
to
receive
(
:to_hash
).
once
diffs
end
it
'uses the diffs from the DB'
do
it
'uses the diffs from the DB'
do
expect
(
diff_with_commits
).
to
receive
(
:load_diffs
)
expect
(
diff_with_commits
).
to
receive
(
:load_diffs
)
...
...
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