OSDN Git Service

Improve commit render performnace for MR show page
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Wed, 22 Jan 2014 13:54:53 +0000 (15:54 +0200)
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Wed, 22 Jan 2014 13:54:53 +0000 (15:54 +0200)
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
app/assets/stylesheets/sections/merge_requests.scss
app/models/merge_request.rb
app/views/projects/commits/_inline_commit.html.haml
app/views/projects/merge_requests/show/_commits.html.haml

index d3462d6..4388da0 100644 (file)
 .merge-request-form-info {
   padding-top: 15px;
 }
-
-.merge-request-branches {
-  .commit-row-message {
-    font-weight: normal !important;
-  }
-
-  .select2-container .select2-single {
-    span {
-      font-weight: bold;
-      color: #555;
-    }
-  }
-}
index 01538cf..076463f 100644 (file)
@@ -150,7 +150,10 @@ class MergeRequest < ActiveRecord::Base
   end
 
   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(
       "(noteable_type = 'MergeRequest' AND noteable_id = :mr_id) OR (noteable_type = 'Commit' AND commit_id IN (:commit_ids))",
       mr_id: id,
index f586346..b36369b 100644 (file)
@@ -2,5 +2,7 @@
   .commit-row-title
     = link_to commit.short_id(8), project_commit_path(project, commit), class: "commit_short_id"
     &nbsp;
-    = link_to_gfm truncate(commit.title, length: 40), project_commit_path(project, commit.id), class: "commit-row-message"
-    #{time_ago_with_tooltip(commit.committed_date)} &nbsp;
+    %span.str-truncated
+      = link_to_gfm commit.title, project_commit_path(project, commit.id), class: "commit-row-message"
+    .pull-right
+      #{time_ago_with_tooltip(commit.committed_date)}
index 7b0e670..8ca1326 100644 (file)
             8 of #{@commits.count} commits displayed.
             %strong
               %a.show-all-commits Click here to show all
-        %ul.all-commits.hide.well-list
-          - @commits.each do |commit|
-            = render "projects/commits/commit", commit: commit, project: @merge_request.source_project
+        - if @commits.size > MergeRequestDiff::COMMITS_SAFE_SIZE
+          %ul.all-commits.hide.well-list
+            - @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
         %ul.well-list