Commit 2ed56ce9d445e0ab22b5c20ec0d28342396d01cf

Authored by Dmitriy Zaporozhets
2 parents 1b60913e 87248267

Merge branch 'speed_up_wiki_pages' into 'master'

Speed up wiki pages page
app/controllers/projects/wikis_controller.rb
@@ -7,7 +7,7 @@ class Projects::WikisController < Projects::ApplicationController @@ -7,7 +7,7 @@ class Projects::WikisController < Projects::ApplicationController
7 before_filter :load_project_wiki 7 before_filter :load_project_wiki
8 8
9 def pages 9 def pages
10 - @wiki_pages = @project_wiki.pages 10 + @wiki_pages = Kaminari.paginate_array(@project_wiki.pages).page(params[:page]).per(30)
11 end 11 end
12 12
13 def show 13 def show
app/models/wiki_page.rb
@@ -61,12 +61,16 @@ class WikiPage @@ -61,12 +61,16 @@ class WikiPage
61 61
62 # The raw content of this page. 62 # The raw content of this page.
63 def content 63 def content
64 - @attributes[:content] 64 + @attributes[:content] ||= if @page
  65 + @page.raw_data
  66 + end
65 end 67 end
66 68
67 # The processed/formatted content of this page. 69 # The processed/formatted content of this page.
68 def formatted_content 70 def formatted_content
69 - @attributes[:formatted_content] 71 + @attributes[:formatted_content] ||= if @page
  72 + @page.formatted_data
  73 + end
70 end 74 end
71 75
72 # The markup format for the page. 76 # The markup format for the page.
@@ -167,8 +171,6 @@ class WikiPage @@ -167,8 +171,6 @@ class WikiPage
167 def set_attributes 171 def set_attributes
168 attributes[:slug] = @page.escaped_url_path 172 attributes[:slug] = @page.escaped_url_path
169 attributes[:title] = @page.title 173 attributes[:title] = @page.title
170 - attributes[:content] = @page.raw_data  
171 - attributes[:formatted_content] = @page.formatted_data  
172 attributes[:format] = @page.format 174 attributes[:format] = @page.format
173 end 175 end
174 176
app/views/projects/wikis/pages.html.haml
@@ -9,3 +9,4 @@ @@ -9,3 +9,4 @@
9 %small (#{wiki_page.format}) 9 %small (#{wiki_page.format})
10 .pull-right 10 .pull-right
11 %small Last edited #{time_ago_with_tooltip(wiki_page.commit.created_at)} 11 %small Last edited #{time_ago_with_tooltip(wiki_page.commit.created_at)}
  12 += paginate @wiki_pages, theme: 'gitlab'