diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2011-03-12 18:09:46 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2011-03-12 18:09:46 +0000 |
commit | b8b35ab05f70e6edd524397d2fb0dca3630fa840 (patch) | |
tree | 47b6925e19f643969a019a5ca094f4a197777bad /app/controllers/wiki_controller.rb | |
parent | f7127e9466861af2a8ea11624e619e6567890a36 (diff) | |
download | redmine-b8b35ab05f70e6edd524397d2fb0dca3630fa840.tar.gz redmine-b8b35ab05f70e6edd524397d2fb0dca3630fa840.zip |
Moved wiki page updated_on eager load to a scope and fixed timestamp titles on wiki page index (#7818).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@5098 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/controllers/wiki_controller.rb')
-rw-r--r-- | app/controllers/wiki_controller.rb | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/app/controllers/wiki_controller.rb b/app/controllers/wiki_controller.rb index e7e389306..f3a9b90ad 100644 --- a/app/controllers/wiki_controller.rb +++ b/app/controllers/wiki_controller.rb @@ -1,5 +1,5 @@ -# redMine - project management software -# Copyright (C) 2006-2007 Jean-Philippe Lang +# Redmine - project management software +# Copyright (C) 2006-2011 Jean-Philippe Lang # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -44,7 +44,14 @@ class WikiController < ApplicationController # List of pages, sorted alphabetically and by parent (hierarchy) def index - load_pages_grouped_by_date_without_content + load_pages_for_index + @pages_by_parent_id = @pages.group_by(&:parent_id) + end + + # List of page, by last update + def date_index + load_pages_for_index + @pages_by_date = @pages.group_by {|p| p.updated_on.to_date} end # display a page (in editing mode if it doesn't exist) @@ -215,10 +222,6 @@ class WikiController < ApplicationController redirect_to :action => 'show', :project_id => @project, :id => nil end end - - def date_index - load_pages_grouped_by_date_without_content - end def preview page = @wiki.find_page(params[:id]) @@ -266,14 +269,8 @@ 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 + def load_pages_for_index + @pages = @wiki.pages.with_updated_on.all(:order => 'title', :include => {:wiki => :project}) + end end |