summaryrefslogtreecommitdiff
path: root/config
diff options
context:
space:
mode:
authorFrancisco Javier López <fjlopez@gitlab.com>2017-11-17 11:48:32 +0000
committerDouwe Maan <douwe@gitlab.com>2017-11-17 11:48:32 +0000
commitff26ea818cb92eabc8fbea1a8385cb5bc6b0a66f (patch)
treee252a9e7be6cc35d76e78745aa6ed437f1279ed1 /config
parent88d29775bbbeaeff7deff8fb1be58905f2535a96 (diff)
downloadgitlab-ce-ff26ea818cb92eabc8fbea1a8385cb5bc6b0a66f.tar.gz
Resolve "Performance issues when loading large number of wiki pages"
Diffstat (limited to 'config')
-rw-r--r--config/initializers/gollum.rb26
1 files changed, 26 insertions, 0 deletions
diff --git a/config/initializers/gollum.rb b/config/initializers/gollum.rb
index 1ebe3c7a742..2ca32791bb1 100644
--- a/config/initializers/gollum.rb
+++ b/config/initializers/gollum.rb
@@ -10,4 +10,30 @@ module Gollum
index.send(name, *args)
end
end
+
+ class Wiki
+ def pages(treeish = nil, limit: nil)
+ tree_list((treeish || @ref), limit: limit)
+ end
+
+ def tree_list(ref, limit: nil)
+ if (sha = @access.ref_to_sha(ref))
+ commit = @access.commit(sha)
+ tree_map_for(sha).inject([]) do |list, entry|
+ next list unless @page_class.valid_page_name?(entry.name)
+ list << entry.page(self, commit)
+ break list if limit && list.size >= limit
+ list
+ end
+ else
+ []
+ end
+ end
+ end
+end
+
+Rails.application.configure do
+ config.after_initialize do
+ Gollum::Page.per_page = Kaminari.config.default_per_page
+ end
end