From: Eric Davis Date: Thu, 14 Oct 2010 18:01:46 +0000 (+0000) Subject: Refactor: extract finder to a utility method X-Git-Tag: 1.1.0~283 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=bbbfd4ee4cf34742c1f0e18cf5709a2f59762b6b;p=redmine.git Refactor: extract finder to a utility method git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4252 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- diff --git a/app/controllers/wiki_controller.rb b/app/controllers/wiki_controller.rb index 10890495f..402483cbc 100644 --- a/app/controllers/wiki_controller.rb +++ b/app/controllers/wiki_controller.rb @@ -175,12 +175,7 @@ class WikiController < ApplicationController case page_title # show pages index, sorted by title when 'page_index', 'date_index' - # eager load information about last updates, without loading text - @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) + load_pages_grouped_by_date_without_content when 'export' redirect_to :action => 'export', :id => @project # Compatibility stub while refactoring return @@ -249,4 +244,14 @@ private extend helper unless self.instance_of?(helper) helper.instance_method(:initial_page_content).bind(self).call(page) 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