/wiki_pages: avoid unnecessary COUNT(*).
@wiki_pages.count issues a COUNT(*), which is unnecessary when we're just counting the ~20 @wiki_pages we've already loaded.
This commit is contained in:
@@ -19,9 +19,9 @@ class WikiPagesController < ApplicationController
|
|||||||
respond_with(@wiki_pages) do |format|
|
respond_with(@wiki_pages) do |format|
|
||||||
format.html do
|
format.html do
|
||||||
if params[:page].nil? || params[:page].to_i == 1
|
if params[:page].nil? || params[:page].to_i == 1
|
||||||
if @wiki_pages.count == 1
|
if @wiki_pages.length == 1
|
||||||
redirect_to(wiki_page_path(@wiki_pages.first))
|
redirect_to(wiki_page_path(@wiki_pages.first))
|
||||||
elsif @wiki_pages.count == 0 && params[:search][:title].present? && params[:search][:title] !~ /\*/
|
elsif @wiki_pages.length == 0 && params[:search][:title].present? && params[:search][:title] !~ /\*/
|
||||||
redirect_to(wiki_pages_path(:search => {:title => "*#{params[:search][:title]}*"}))
|
redirect_to(wiki_pages_path(:search => {:title => "*#{params[:search][:title]}*"}))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user