Commit 51ea42e2386f109e3fb4f3619dd33eb9a5398080

Authored by Dmitriy Zaporozhets
1 parent 39a86963

Improve commit render performnace for MR show page

Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
app/assets/stylesheets/sections/merge_requests.scss
... ... @@ -89,16 +89,3 @@
89 89 .merge-request-form-info {
90 90 padding-top: 15px;
91 91 }
92   -
93   -.merge-request-branches {
94   - .commit-row-message {
95   - font-weight: normal !important;
96   - }
97   -
98   - .select2-container .select2-single {
99   - span {
100   - font-weight: bold;
101   - color: #555;
102   - }
103   - }
104   -}
... ...
app/models/merge_request.rb
... ... @@ -150,7 +150,10 @@ class MergeRequest &lt; ActiveRecord::Base
150 150 end
151 151  
152 152 def mr_and_commit_notes
153   - commit_ids = commits.map(&:id)
  153 + # Fetch comments only from last 100 commits
  154 + commits_for_notes_limit = 100
  155 + commit_ids = commits.last(commits_for_notes_limit).map(&:id)
  156 +
154 157 project.notes.where(
155 158 "(noteable_type = 'MergeRequest' AND noteable_id = :mr_id) OR (noteable_type = 'Commit' AND commit_id IN (:commit_ids))",
156 159 mr_id: id,
... ...
app/views/projects/commits/_inline_commit.html.haml
... ... @@ -2,5 +2,7 @@
2 2 .commit-row-title
3 3 = link_to commit.short_id(8), project_commit_path(project, commit), class: "commit_short_id"
4 4 &nbsp;
5   - = link_to_gfm truncate(commit.title, length: 40), project_commit_path(project, commit.id), class: "commit-row-message"
6   - #{time_ago_with_tooltip(commit.committed_date)} &nbsp;
  5 + %span.str-truncated
  6 + = link_to_gfm commit.title, project_commit_path(project, commit.id), class: "commit-row-message"
  7 + .pull-right
  8 + #{time_ago_with_tooltip(commit.committed_date)}
... ...
app/views/projects/merge_requests/show/_commits.html.haml
... ... @@ -12,9 +12,16 @@
12 12 8 of #{@commits.count} commits displayed.
13 13 %strong
14 14 %a.show-all-commits Click here to show all
15   - %ul.all-commits.hide.well-list
16   - - @commits.each do |commit|
17   - = render "projects/commits/commit", commit: commit, project: @merge_request.source_project
  15 + - if @commits.size > MergeRequestDiff::COMMITS_SAFE_SIZE
  16 + %ul.all-commits.hide.well-list
  17 + - @commits.first(MergeRequestDiff::COMMITS_SAFE_SIZE).each do |commit|
  18 + = render "projects/commits/inline_commit", commit: commit, project: @merge_request.source_project
  19 + %li
  20 + other #{@commits.size - MergeRequestDiff::COMMITS_SAFE_SIZE} commits hidden top prevent performance issues.
  21 + - else
  22 + %ul.all-commits.hide.well-list
  23 + - @commits.each do |commit|
  24 + = render "projects/commits/inline_commit", commit: commit, project: @merge_request.source_project
18 25  
19 26 - else
20 27 %ul.well-list
... ...