diff --git a/lib/diaspora/user/querying.rb b/lib/diaspora/user/querying.rb index 4cca38c3e..7a50bcaef 100644 --- a/lib/diaspora/user/querying.rb +++ b/lib/diaspora/user/querying.rb @@ -78,7 +78,7 @@ module Diaspora def posts_from(person) asp = Aspect.arel_table p = Post.arel_table - person.posts.includes(:aspects).where( p[:public].eq(true).or(asp[:user_id].eq(self.id))).select('DISTINCT `posts`.*').order("posts.updated_at DESC") + person.posts.includes(:aspects, :comments => {:person => :profile}).where( p[:public].eq(true).or(asp[:user_id].eq(self.id))).select('DISTINCT `posts`.*').order("posts.updated_at DESC") end end end diff --git a/spec/controllers/people_controller_spec.rb b/spec/controllers/people_controller_spec.rb index 2f603cccf..f6a4ef56d 100644 --- a/spec/controllers/people_controller_spec.rb +++ b/spec/controllers/people_controller_spec.rb @@ -122,7 +122,32 @@ describe PeopleController do get :show, :id => @user.person.id response.should be_success end + describe 'performance' do + before do + require 'benchmark' + @posts = [] + @users = [] + 8.times do |n| + user = Factory.create(:user) + @users << user + aspect = user.aspects.create(:name => 'people') + connect_users(@user, @user.aspects.first, user, aspect) + @posts << @user.post(:status_message, :message => "hello#{n}", :to => aspect.id) + end + @posts.each do |post| + @users.each do |user| + user.comment "yo#{post.message}", :on => post + end + end + end + + it 'takes time' do + Benchmark.realtime{ + get :show, :id => @user.person.id + }.should < 0.2 + end + end it 'renders with a post' do @user.post :status_message, :message => 'test more', :to => @aspect.id get :show, :id => @user.person.id