try an in query directly for the tags
This commit is contained in:
parent
0aa49a8d73
commit
34f82d8bc1
3 changed files with 13 additions and 3 deletions
|
|
@ -10,7 +10,6 @@ class TagFollowingsController < ApplicationController
|
|||
|
||||
def index
|
||||
@stream = TagStream.new(current_user, :max_time => params[:max_time], :order => sort_order)
|
||||
|
||||
if params[:only_posts]
|
||||
render :partial => 'shared/stream', :locals => {:posts => @stream.posts}
|
||||
else
|
||||
|
|
|
|||
|
|
@ -18,8 +18,7 @@ class TagStream < BaseStream
|
|||
[]
|
||||
else
|
||||
@posts ||= StatusMessage.owned_or_visible_by_user(user).
|
||||
tagged_with([tag_string], :any => true).
|
||||
where(:public => true).
|
||||
joins(:tags).where(:tags => {:name => tag_array}).
|
||||
for_a_stream(@max_time, @order)
|
||||
end
|
||||
end
|
||||
|
|
@ -39,6 +38,10 @@ class TagStream < BaseStream
|
|||
@tag_string ||= tags.join(', '){|tag| tag.name}.to_s
|
||||
end
|
||||
|
||||
def tag_array
|
||||
tags.map{|x| x.name}
|
||||
end
|
||||
|
||||
def tags
|
||||
@tags = user.followed_tags
|
||||
end
|
||||
|
|
|
|||
|
|
@ -4,9 +4,17 @@ require File.join(Rails.root, 'spec', 'shared_behaviors', 'stream')
|
|||
describe TagStream do
|
||||
before do
|
||||
@stream = TagStream.new(Factory(:user), :max_time => Time.now, :order => 'updated_at')
|
||||
@stream.stub(:tag_string).and_return("foo")
|
||||
end
|
||||
|
||||
describe 'shared behaviors' do
|
||||
it_should_behave_like 'it is a stream'
|
||||
end
|
||||
|
||||
|
||||
describe 'posts' do
|
||||
it 'explains the query' do
|
||||
puts @stream.posts.to_sql
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue