/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:
evazion
2017-03-29 13:46:27 -05:00
parent fcc5521f63
commit 85a39cadf0

View File

@@ -19,9 +19,9 @@ class WikiPagesController < ApplicationController
respond_with(@wiki_pages) do |format|
format.html do
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))
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]}*"}))
end
end