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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
e4027e40
Commit
e4027e40
authored
Jul 28, 2016
by
Ahmad Sherif
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reduce number of queries made for merge_requests/:id/diffs
parent
a88a4e85
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
12 additions
and
3 deletions
+12
-3
CHANGELOG
CHANGELOG
+1
-0
app/controllers/projects/merge_requests_controller.rb
app/controllers/projects/merge_requests_controller.rb
+1
-1
app/models/concerns/issuable.rb
app/models/concerns/issuable.rb
+1
-1
app/models/legacy_diff_note.rb
app/models/legacy_diff_note.rb
+9
-1
No files found.
CHANGELOG
View file @
e4027e40
...
@@ -25,6 +25,7 @@ v 8.11.0 (unreleased)
...
@@ -25,6 +25,7 @@ v 8.11.0 (unreleased)
- Add commit stats in commit api. !5517 (dixpac)
- Add commit stats in commit api. !5517 (dixpac)
- Make error pages responsive (Takuya Noguchi)
- Make error pages responsive (Takuya Noguchi)
- Change requests_profiles resource constraint to catch virtually any file
- Change requests_profiles resource constraint to catch virtually any file
- Reduce number of queries made for merge_requests/:id/diffs
v 8.10.3 (unreleased)
v 8.10.3 (unreleased)
...
...
app/controllers/projects/merge_requests_controller.rb
View file @
e4027e40
...
@@ -407,7 +407,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController
...
@@ -407,7 +407,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController
}
}
@use_legacy_diff_notes
=
!
@merge_request
.
support_new_diff_notes?
@use_legacy_diff_notes
=
!
@merge_request
.
support_new_diff_notes?
@grouped_diff_discussions
=
@merge_request
.
notes
.
grouped_diff_discussions
@grouped_diff_discussions
=
@merge_request
.
notes
.
inc_author_project_award_emoji
.
grouped_diff_discussions
Banzai
::
NoteRenderer
.
render
(
Banzai
::
NoteRenderer
.
render
(
@grouped_diff_discussions
.
values
.
flat_map
(
&
:notes
),
@grouped_diff_discussions
.
values
.
flat_map
(
&
:notes
),
...
...
app/models/concerns/issuable.rb
View file @
e4027e40
...
@@ -17,7 +17,7 @@ module Issuable
...
@@ -17,7 +17,7 @@ module Issuable
belongs_to
:assignee
,
class_name:
"User"
belongs_to
:assignee
,
class_name:
"User"
belongs_to
:updated_by
,
class_name:
"User"
belongs_to
:updated_by
,
class_name:
"User"
belongs_to
:milestone
belongs_to
:milestone
has_many
:notes
,
as: :noteable
,
dependent: :destroy
do
has_many
:notes
,
as: :noteable
,
inverse_of: :noteable
,
dependent: :destroy
do
def
authors_loaded?
def
authors_loaded?
# We check first if we're loaded to not load unnecessarily.
# We check first if we're loaded to not load unnecessarily.
loaded?
&&
to_a
.
all?
{
|
note
|
note
.
association
(
:author
).
loaded?
}
loaded?
&&
to_a
.
all?
{
|
note
|
note
.
association
(
:author
).
loaded?
}
...
...
app/models/legacy_diff_note.rb
View file @
e4027e40
...
@@ -25,6 +25,14 @@ class LegacyDiffNote < Note
...
@@ -25,6 +25,14 @@ class LegacyDiffNote < Note
@discussion_id
||=
self
.
class
.
build_discussion_id
(
noteable_type
,
noteable_id
||
commit_id
,
line_code
)
@discussion_id
||=
self
.
class
.
build_discussion_id
(
noteable_type
,
noteable_id
||
commit_id
,
line_code
)
end
end
def
project_repository
if
RequestStore
.
active?
RequestStore
.
fetch
(
"project:
#{
project_id
}
:repository"
)
{
self
.
project
.
repository
}
else
self
.
project
.
repository
end
end
def
diff_file_hash
def
diff_file_hash
line_code
.
split
(
'_'
)[
0
]
if
line_code
line_code
.
split
(
'_'
)[
0
]
if
line_code
end
end
...
@@ -34,7 +42,7 @@ class LegacyDiffNote < Note
...
@@ -34,7 +42,7 @@ class LegacyDiffNote < Note
end
end
def
diff_file
def
diff_file
@diff_file
||=
Gitlab
::
Diff
::
File
.
new
(
diff
,
repository:
self
.
project
.
repository
)
if
diff
@diff_file
||=
Gitlab
::
Diff
::
File
.
new
(
diff
,
repository:
project_
repository
)
if
diff
end
end
def
diff_line
def
diff_line
...
...
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