Merge pull request #3071 from evazion/fix-order-index

Fix #3000: order: metatags aren't indexed.
This commit is contained in:
Albert Yi
2017-05-22 11:39:00 -07:00
committed by GitHub
4 changed files with 36 additions and 12 deletions

View File

@@ -78,7 +78,7 @@ private
end
def index_by_post
@posts = Post.where("last_comment_bumped_at IS NOT NULL").tag_match(params[:tags]).reorder("last_comment_bumped_at DESC").paginate(params[:page], :limit => 5, :search_count => params[:search])
@posts = Post.where("last_comment_bumped_at IS NOT NULL").tag_match(params[:tags]).reorder("last_comment_bumped_at DESC NULLS LAST").paginate(params[:page], :limit => 5, :search_count => params[:search])
@posts.each # hack to force rails to eager load
respond_with(@posts) do |format|
format.html {render :action => "index_by_post"}

View File

@@ -392,34 +392,34 @@ class PostQueryBuilder
relation = relation.order("posts.id DESC")
when "score", "score_desc"
relation = relation.order("posts.score DESC")
relation = relation.order("posts.score DESC, posts.id DESC")
when "score_asc"
relation = relation.order("posts.score ASC")
relation = relation.order("posts.score ASC, posts.id ASC")
when "favcount"
relation = relation.order("posts.fav_count DESC")
relation = relation.order("posts.fav_count DESC, posts.id DESC")
when "favcount_asc"
relation = relation.order("posts.fav_count ASC")
relation = relation.order("posts.fav_count ASC, posts.id ASC")
when "change", "change_desc"
relation = relation.order("posts.updated_at DESC")
relation = relation.order("posts.updated_at DESC, posts.id DESC")
when "change_asc"
relation = relation.order("posts.updated_at ASC")
relation = relation.order("posts.updated_at ASC, posts.id ASC")
when "comment", "comm"
relation = relation.order("posts.last_commented_at DESC NULLS LAST")
relation = relation.order("posts.last_commented_at DESC NULLS LAST, posts.id DESC")
when "comment_asc", "comm_asc"
relation = relation.order("posts.last_commented_at ASC NULLS LAST")
relation = relation.order("posts.last_commented_at ASC NULLS LAST, posts.id ASC")
when "comment_bumped"
relation = relation.order("posts.last_comment_bumped_at DESC NULLS LAST")
when "comment_bumped_asc"
relation = relation.order("posts.last_comment_bumped_at ASC NULLS LAST")
relation = relation.order("posts.last_comment_bumped_at ASC NULLS FIRST")
when "note"
relation = relation.order("posts.last_noted_at DESC NULLS LAST")