Commit 51ea42e2 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Improve commit render performnace for MR show page

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent 39a86963
...@@ -89,16 +89,3 @@ ...@@ -89,16 +89,3 @@
.merge-request-form-info { .merge-request-form-info {
padding-top: 15px; padding-top: 15px;
} }
.merge-request-branches {
.commit-row-message {
font-weight: normal !important;
}
.select2-container .select2-single {
span {
font-weight: bold;
color: #555;
}
}
}
...@@ -150,7 +150,10 @@ class MergeRequest < ActiveRecord::Base ...@@ -150,7 +150,10 @@ class MergeRequest < ActiveRecord::Base
end end
def mr_and_commit_notes def mr_and_commit_notes
commit_ids = commits.map(&:id) # Fetch comments only from last 100 commits
commits_for_notes_limit = 100
commit_ids = commits.last(commits_for_notes_limit).map(&:id)
project.notes.where( project.notes.where(
"(noteable_type = 'MergeRequest' AND noteable_id = :mr_id) OR (noteable_type = 'Commit' AND commit_id IN (:commit_ids))", "(noteable_type = 'MergeRequest' AND noteable_id = :mr_id) OR (noteable_type = 'Commit' AND commit_id IN (:commit_ids))",
mr_id: id, mr_id: id,
......
...@@ -2,5 +2,7 @@ ...@@ -2,5 +2,7 @@
.commit-row-title .commit-row-title
= link_to commit.short_id(8), project_commit_path(project, commit), class: "commit_short_id" = link_to commit.short_id(8), project_commit_path(project, commit), class: "commit_short_id"
&nbsp; &nbsp;
= link_to_gfm truncate(commit.title, length: 40), project_commit_path(project, commit.id), class: "commit-row-message" %span.str-truncated
#{time_ago_with_tooltip(commit.committed_date)} &nbsp; = link_to_gfm commit.title, project_commit_path(project, commit.id), class: "commit-row-message"
.pull-right
#{time_ago_with_tooltip(commit.committed_date)}
...@@ -12,9 +12,16 @@ ...@@ -12,9 +12,16 @@
8 of #{@commits.count} commits displayed. 8 of #{@commits.count} commits displayed.
%strong %strong
%a.show-all-commits Click here to show all %a.show-all-commits Click here to show all
%ul.all-commits.hide.well-list - if @commits.size > MergeRequestDiff::COMMITS_SAFE_SIZE
- @commits.each do |commit| %ul.all-commits.hide.well-list
= render "projects/commits/commit", commit: commit, project: @merge_request.source_project - @commits.first(MergeRequestDiff::COMMITS_SAFE_SIZE).each do |commit|
= render "projects/commits/inline_commit", commit: commit, project: @merge_request.source_project
%li
other #{@commits.size - MergeRequestDiff::COMMITS_SAFE_SIZE} commits hidden top prevent performance issues.
- else
%ul.all-commits.hide.well-list
- @commits.each do |commit|
= render "projects/commits/inline_commit", commit: commit, project: @merge_request.source_project
- else - else
%ul.well-list %ul.well-list
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment