Refactor: extract finder to a utility method
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4252 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
e8468b51cc
commit
bbbfd4ee4c
@ -175,12 +175,7 @@ class WikiController < ApplicationController
|
|||||||
case page_title
|
case page_title
|
||||||
# show pages index, sorted by title
|
# show pages index, sorted by title
|
||||||
when 'page_index', 'date_index'
|
when 'page_index', 'date_index'
|
||||||
# eager load information about last updates, without loading text
|
load_pages_grouped_by_date_without_content
|
||||||
@pages = @wiki.pages.find :all, :select => "#{WikiPage.table_name}.*, #{WikiContent.table_name}.updated_on",
|
|
||||||
:joins => "LEFT JOIN #{WikiContent.table_name} ON #{WikiContent.table_name}.page_id = #{WikiPage.table_name}.id",
|
|
||||||
:order => 'title'
|
|
||||||
@pages_by_date = @pages.group_by {|p| p.updated_on.to_date}
|
|
||||||
@pages_by_parent_id = @pages.group_by(&:parent_id)
|
|
||||||
when 'export'
|
when 'export'
|
||||||
redirect_to :action => 'export', :id => @project # Compatibility stub while refactoring
|
redirect_to :action => 'export', :id => @project # Compatibility stub while refactoring
|
||||||
return
|
return
|
||||||
@ -249,4 +244,14 @@ private
|
|||||||
extend helper unless self.instance_of?(helper)
|
extend helper unless self.instance_of?(helper)
|
||||||
helper.instance_method(:initial_page_content).bind(self).call(page)
|
helper.instance_method(:initial_page_content).bind(self).call(page)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# eager load information about last updates, without loading text
|
||||||
|
def load_pages_grouped_by_date_without_content
|
||||||
|
@pages = @wiki.pages.find :all, :select => "#{WikiPage.table_name}.*, #{WikiContent.table_name}.updated_on",
|
||||||
|
:joins => "LEFT JOIN #{WikiContent.table_name} ON #{WikiContent.table_name}.page_id = #{WikiPage.table_name}.id",
|
||||||
|
:order => 'title'
|
||||||
|
@pages_by_date = @pages.group_by {|p| p.updated_on.to_date}
|
||||||
|
@pages_by_parent_id = @pages.group_by(&:parent_id)
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user