@@ -175,12 +175,7 class WikiController < ApplicationController | |||||
175 | case page_title |
|
175 | case page_title | |
176 | # show pages index, sorted by title |
|
176 | # show pages index, sorted by title | |
177 | when 'page_index', 'date_index' |
|
177 | when 'page_index', 'date_index' | |
178 | # eager load information about last updates, without loading text |
|
178 | load_pages_grouped_by_date_without_content | |
179 | @pages = @wiki.pages.find :all, :select => "#{WikiPage.table_name}.*, #{WikiContent.table_name}.updated_on", |
|
|||
180 | :joins => "LEFT JOIN #{WikiContent.table_name} ON #{WikiContent.table_name}.page_id = #{WikiPage.table_name}.id", |
|
|||
181 | :order => 'title' |
|
|||
182 | @pages_by_date = @pages.group_by {|p| p.updated_on.to_date} |
|
|||
183 | @pages_by_parent_id = @pages.group_by(&:parent_id) |
|
|||
184 | when 'export' |
|
179 | when 'export' | |
185 | redirect_to :action => 'export', :id => @project # Compatibility stub while refactoring |
|
180 | redirect_to :action => 'export', :id => @project # Compatibility stub while refactoring | |
186 | return |
|
181 | return | |
@@ -249,4 +244,14 private | |||||
249 | extend helper unless self.instance_of?(helper) |
|
244 | extend helper unless self.instance_of?(helper) | |
250 | helper.instance_method(:initial_page_content).bind(self).call(page) |
|
245 | helper.instance_method(:initial_page_content).bind(self).call(page) | |
251 | end |
|
246 | end | |
|
247 | ||||
|
248 | # eager load information about last updates, without loading text | |||
|
249 | def load_pages_grouped_by_date_without_content | |||
|
250 | @pages = @wiki.pages.find :all, :select => "#{WikiPage.table_name}.*, #{WikiContent.table_name}.updated_on", | |||
|
251 | :joins => "LEFT JOIN #{WikiContent.table_name} ON #{WikiContent.table_name}.page_id = #{WikiPage.table_name}.id", | |||
|
252 | :order => 'title' | |||
|
253 | @pages_by_date = @pages.group_by {|p| p.updated_on.to_date} | |||
|
254 | @pages_by_parent_id = @pages.group_by(&:parent_id) | |||
|
255 | end | |||
|
256 | ||||
252 | end |
|
257 | end |
General Comments 0
You need to be logged in to leave comments.
Login now