Don't show commented tags in the tag stream for now, until we optimize that

This commit is contained in:
Raphael Sofaer 2011-07-07 15:39:28 -07:00
parent e98cc4b960
commit 968100860a
2 changed files with 5 additions and 11 deletions

View file

@ -56,18 +56,11 @@ class TagsController < ApplicationController
@posts = StatusMessage.where(:public => true, :pending => false)
end
@tag = ActsAsTaggableOn::Tag.where(:name => params[:name]).first
if @tag
@posts = @posts.joins("LEFT OUTER JOIN comments ON comments.post_id = posts.id").
joins("INNER JOIN taggings ON (taggings.tag_id = #{@tag.id} AND
((taggable_id = posts.id AND taggable_type = 'Post') OR (taggings.taggable_type = 'Comment' AND taggings.taggable_id = comments.id)))")
@posts = @posts.tagged_with(params[:name])
max_time = params[:max_time] ? Time.at(params[:max_time].to_i) : Time.now
@posts = @posts.where(StatusMessage.arel_table[:created_at].lt(max_time))
@posts = @posts.includes({:comments => {:author => :profile}}, :photos).order('taggings.created_at DESC').limit(15)
else
@posts = []
end
@posts = @posts.includes(:comments, :photos).order('posts.created_at DESC').limit(15)
@posts = PostsFake.new(@posts)
@commenting_disabled = true

View file

@ -71,6 +71,7 @@ describe TagsController do
end
it 'displays a post with a comment containing the tag search' do
pending "toooo slow"
bob.post(:status_message, :text => "other post y'all", :to => 'all')
other_post = bob.post(:status_message, :text => "sup y'all", :to => 'all')
Factory(:comment, :text => "#hello", :post => other_post)