OSDN Git Service

Dont load diff in compare over 100 commits
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Wed, 20 Mar 2013 08:19:00 +0000 (10:19 +0200)
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Wed, 20 Mar 2013 08:19:00 +0000 (10:19 +0200)
app/models/commit.rb
app/views/compare/show.html.haml

index 17d41f2..daba541 100644 (file)
@@ -89,7 +89,14 @@ class Commit
       if first && last
         result[:same] = (first.id == last.id)
         result[:commits] = project.repo.commits_between(last.id, first.id).map {|c| Commit.new(c)}
-        result[:diffs] = project.repo.diff(last.id, first.id) rescue []
+
+        # Dont load diff for 100+ commits
+        result[:diffs] = if result[:commits].size > 100
+                           []
+                         else
+                           project.repo.diff(last.id, first.id) rescue []
+                         end
+
         result[:commit] = Commit.new(first)
       end
 
index d8ea372..476be25 100644 (file)
@@ -6,6 +6,12 @@
 
 = render "form"
 
+- if @commits.size > 100
+  .alert.alert-block
+    %p
+      %strong Warning! This comparison include 100+ commits.
+    %p To prevent performance issue we dont show diff information.
+
 - if @commits.present?
   %div.ui-box
     %h5.title