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
Jérome Perrin
gitlab-ce
Commits
6a355d45
Commit
6a355d45
authored
Aug 18, 2016
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve performance of MR show page
parent
ac89bb0f
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
33 additions
and
22 deletions
+33
-22
app/controllers/projects/merge_requests_controller.rb
app/controllers/projects/merge_requests_controller.rb
+1
-1
app/helpers/appearances_helper.rb
app/helpers/appearances_helper.rb
+2
-0
app/models/diff_note.rb
app/models/diff_note.rb
+0
-2
app/models/merge_request.rb
app/models/merge_request.rb
+1
-1
app/models/note.rb
app/models/note.rb
+4
-1
app/views/discussions/_diff_with_notes.html.haml
app/views/discussions/_diff_with_notes.html.haml
+8
-5
app/views/notify/repository_push_email.html.haml
app/views/notify/repository_push_email.html.haml
+1
-2
app/views/projects/diffs/_line.html.haml
app/views/projects/diffs/_line.html.haml
+8
-1
app/views/projects/diffs/_text_file.html.haml
app/views/projects/diffs/_text_file.html.haml
+8
-9
No files found.
app/controllers/projects/merge_requests_controller.rb
View file @
6a355d45
...
@@ -471,7 +471,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController
...
@@ -471,7 +471,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController
}
}
@use_legacy_diff_notes
=
!
@merge_request
.
has_complete_diff_refs?
@use_legacy_diff_notes
=
!
@merge_request
.
has_complete_diff_refs?
@grouped_diff_discussions
=
@merge_request
.
notes
.
inc_
author_project_award_emoji
.
grouped_diff_discussions
@grouped_diff_discussions
=
@merge_request
.
notes
.
inc_
relations_for_view
.
grouped_diff_discussions
Banzai
::
NoteRenderer
.
render
(
Banzai
::
NoteRenderer
.
render
(
@grouped_diff_discussions
.
values
.
flat_map
(
&
:notes
),
@grouped_diff_discussions
.
values
.
flat_map
(
&
:notes
),
...
...
app/helpers/appearances_helper.rb
View file @
6a355d45
...
@@ -32,6 +32,8 @@ module AppearancesHelper
...
@@ -32,6 +32,8 @@ module AppearancesHelper
end
end
def
custom_icon
(
icon_name
,
size:
16
)
def
custom_icon
(
icon_name
,
size:
16
)
# We can't simply do the below, because there are some .erb SVGs.
# File.read(Rails.root.join("app/views/shared/icons/_#{icon_name}.svg")).html_safe
render
"shared/icons/
#{
icon_name
}
.svg"
,
size:
size
render
"shared/icons/
#{
icon_name
}
.svg"
,
size:
size
end
end
end
end
app/models/diff_note.rb
View file @
6a355d45
...
@@ -4,8 +4,6 @@ class DiffNote < Note
...
@@ -4,8 +4,6 @@ class DiffNote < Note
serialize
:original_position
,
Gitlab
::
Diff
::
Position
serialize
:original_position
,
Gitlab
::
Diff
::
Position
serialize
:position
,
Gitlab
::
Diff
::
Position
serialize
:position
,
Gitlab
::
Diff
::
Position
belongs_to
:resolved_by
,
class_name:
"User"
validates
:original_position
,
presence:
true
validates
:original_position
,
presence:
true
validates
:position
,
presence:
true
validates
:position
,
presence:
true
validates
:diff_line
,
presence:
true
validates
:diff_line
,
presence:
true
...
...
app/models/merge_request.rb
View file @
6a355d45
...
@@ -420,7 +420,7 @@ class MergeRequest < ActiveRecord::Base
...
@@ -420,7 +420,7 @@ class MergeRequest < ActiveRecord::Base
def
discussions
def
discussions
@discussions
||=
self
.
mr_and_commit_notes
.
@discussions
||=
self
.
mr_and_commit_notes
.
inc_
author_project_award_emoji
.
inc_
relations_for_view
.
fresh
.
fresh
.
discussions
discussions
end
end
...
...
app/models/note.rb
View file @
6a355d45
...
@@ -25,6 +25,9 @@ class Note < ActiveRecord::Base
...
@@ -25,6 +25,9 @@ class Note < ActiveRecord::Base
belongs_to
:author
,
class_name:
"User"
belongs_to
:author
,
class_name:
"User"
belongs_to
:updated_by
,
class_name:
"User"
belongs_to
:updated_by
,
class_name:
"User"
# Only used by DiffNote, but defined here so that it can be used in `Note.includes`
belongs_to
:resolved_by
,
class_name:
"User"
has_many
:todos
,
dependent: :destroy
has_many
:todos
,
dependent: :destroy
has_many
:events
,
as: :target
,
dependent: :destroy
has_many
:events
,
as: :target
,
dependent: :destroy
...
@@ -59,7 +62,7 @@ class Note < ActiveRecord::Base
...
@@ -59,7 +62,7 @@ class Note < ActiveRecord::Base
scope
:fresh
,
->
{
order
(
created_at: :asc
,
id: :asc
)
}
scope
:fresh
,
->
{
order
(
created_at: :asc
,
id: :asc
)
}
scope
:inc_author_project
,
->
{
includes
(
:project
,
:author
)
}
scope
:inc_author_project
,
->
{
includes
(
:project
,
:author
)
}
scope
:inc_author
,
->
{
includes
(
:author
)
}
scope
:inc_author
,
->
{
includes
(
:author
)
}
scope
:inc_
author_project_award_emoji
,
->
{
includes
(
:project
,
:author
,
:award_emoji
)
}
scope
:inc_
relations_for_view
,
->
{
includes
(
:project
,
:author
,
:updated_by
,
:resolved_by
,
:award_emoji
)
}
scope
:diff_notes
,
->
{
where
(
type:
[
'LegacyDiffNote'
,
'DiffNote'
])
}
scope
:diff_notes
,
->
{
where
(
type:
[
'LegacyDiffNote'
,
'DiffNote'
])
}
scope
:non_diff_notes
,
->
{
where
(
type:
[
'Note'
,
nil
])
}
scope
:non_diff_notes
,
->
{
where
(
type:
[
'Note'
,
nil
])
}
...
...
app/views/discussions/_diff_with_notes.html.haml
View file @
6a355d45
...
@@ -7,8 +7,11 @@
...
@@ -7,8 +7,11 @@
.diff-content.code.js-syntax-highlight
.diff-content.code.js-syntax-highlight
%table
%table
-
discussion
.
truncated_diff_lines
.
each
do
|
line
|
-
discussions
=
{
discussion
.
line_code
=>
discussion
}
=
render
"projects/diffs/line"
,
line:
line
,
diff_file:
diff_file
,
plain:
true
=
render
partial:
"projects/diffs/line"
,
collection:
discussion
.
truncated_diff_lines
,
-
if
discussion
.
for_line?
(
line
)
as: :line
,
=
render
"discussions/diff_discussion"
,
discussion:
discussion
,
expanded:
true
locals:
{
diff_file:
diff_file
,
discussions:
discussions
,
discussion_expanded:
true
,
plain:
true
}
app/views/notify/repository_push_email.html.haml
View file @
6a355d45
...
@@ -75,8 +75,7 @@
...
@@ -75,8 +75,7 @@
-
blob
=
diff_file
.
blob
-
blob
=
diff_file
.
blob
-
if
blob
&&
blob
.
respond_to?
(
:text?
)
&&
blob_text_viewable?
(
blob
)
-
if
blob
&&
blob
.
respond_to?
(
:text?
)
&&
blob_text_viewable?
(
blob
)
%table
.code.white
%table
.code.white
-
diff_file
.
highlighted_diff_lines
.
each
do
|
line
|
=
render
partial:
"projects/diffs/line"
,
collection:
diff_file
.
highlighted_diff_lines
,
as: :line
,
locals:
{
diff_file:
diff_file
,
plain:
true
,
email:
true
}
=
render
"projects/diffs/line"
,
line:
line
,
diff_file:
diff_file
,
plain:
true
,
email:
true
-
else
-
else
No
preview
for
this
file
type
No
preview
for
this
file
type
%br
%br
app/views/projects/diffs/_line.html.haml
View file @
6a355d45
-
email
=
local_assigns
.
fetch
(
:email
,
false
)
-
email
=
local_assigns
.
fetch
(
:email
,
false
)
-
plain
=
local_assigns
.
fetch
(
:plain
,
false
)
-
plain
=
local_assigns
.
fetch
(
:plain
,
false
)
-
type
=
line
.
type
-
type
=
line
.
type
-
line_code
=
diff_file
.
line_code
(
line
)
unless
plain
-
line_code
=
diff_file
.
line_code
(
line
)
%tr
.line_holder
{
plain
?
{
class:
type
}
:
{
class:
type
,
id:
line_code
}
}
%tr
.line_holder
{
plain
?
{
class:
type
}
:
{
class:
type
,
id:
line_code
}
}
-
case
type
-
case
type
-
when
'match'
-
when
'match'
...
@@ -28,3 +28,10 @@
...
@@ -28,3 +28,10 @@
%pre
=
diff_line_content
(
line
.
text
,
type
)
%pre
=
diff_line_content
(
line
.
text
,
type
)
-
else
-
else
=
diff_line_content
(
line
.
text
,
type
)
=
diff_line_content
(
line
.
text
,
type
)
-
discussions
=
local_assigns
.
fetch
(
:discussions
,
nil
)
-
discussion_expanded
=
local_assigns
.
fetch
(
:discussion_expanded
,
false
)
-
if
discussions
&&
!
line
.
meta?
-
discussion
=
discussions
[
line_code
]
-
if
discussion
=
render
"discussions/diff_discussion"
,
discussion:
discussion
,
expanded:
discussion_expanded
app/views/projects/diffs/_text_file.html.haml
View file @
6a355d45
...
@@ -5,15 +5,14 @@
...
@@ -5,15 +5,14 @@
%table
.text-file.code.js-syntax-highlight
{
data:
diff_view_data
,
class:
too_big
?
'hide'
:
''
}
%table
.text-file.code.js-syntax-highlight
{
data:
diff_view_data
,
class:
too_big
?
'hide'
:
''
}
-
last_line
=
0
-
last_line
=
0
-
diff_file
.
highlighted_diff_lines
.
each
do
|
line
|
-
discussions
=
@grouped_diff_discussions
unless
@diff_notes_disabled
-
last_line
=
line
.
new_pos
=
render
partial:
"projects/diffs/line"
,
=
render
"projects/diffs/line"
,
line:
line
,
diff_file:
diff_file
collection:
diff_file
.
highlighted_diff_lines
,
as: :line
,
-
unless
@diff_notes_disabled
locals:
{
diff_file:
diff_file
,
-
line_code
=
diff_file
.
line_code
(
line
)
discussions:
discussions
,
-
discussion
=
@grouped_diff_discussions
[
line_code
]
if
line_code
plain:
true
}
-
if
discussion
=
render
"discussions/diff_discussion"
,
discussion:
discussion
-
last_line
=
diff_file
.
highlighted_diff_lines
.
last
.
new_pos
-
if
!
diff_file
.
new_file
&&
last_line
>
0
-
if
!
diff_file
.
new_file
&&
last_line
>
0
=
diff_match_line
last_line
,
last_line
,
bottom:
true
=
diff_match_line
last_line
,
last_line
,
bottom:
true
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