diff --git a/app/models/user/querying.rb b/app/models/user/querying.rb index c849b13a7..4f53e0351 100644 --- a/app/models/user/querying.rb +++ b/app/models/user/querying.rb @@ -68,10 +68,8 @@ module User::Querying end def construct_public_followings_sql(opts) - aspects = Aspect.where(:id => opts[:by_members_of]) - person_ids = Person.connection.select_values(people_in_aspects(aspects).select("people.id").to_sql) - - query = opts[:klass].where(:author_id => person_ids, :public => true, :pending => false) + Rails.logger.debug("[EVIL-QUERY] user.construct_public_followings_sql") + query = opts[:klass].where(:author_id => Person.in_aspects(opts[:by_members_of]).select("people.id"), :public => true, :pending => false) unless(opts[:klass] == Photo) query = query.where(:type => opts[:type]) diff --git a/config/environments/development.rb b/config/environments/development.rb index 8c22c98c9..309cbce28 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -27,7 +27,7 @@ Diaspora::Application.configure do # Log the query plan for queries taking more than this (works # with SQLite, MySQL, and PostgreSQL) - config.active_record.auto_explain_threshold_in_seconds = 0.5 + # config.active_record.auto_explain_threshold_in_seconds = 0.5 # Do not compress assets config.assets.compress = false diff --git a/lib/evil_query.rb b/lib/evil_query.rb index 0753b0e0c..a9923d4cd 100644 --- a/lib/evil_query.rb +++ b/lib/evil_query.rb @@ -51,20 +51,24 @@ module EvilQuery end def make_relation! + Rails.logger.debug("[EVIL-QUERY] make_relation!") post_ids = aspects_post_ids! + ids!(followed_tags_posts!) + ids!(mentioned_posts) post_ids += ids!(community_spotlight_posts!) if @include_spotlight Post.where(:id => post_ids) end def aspects_post_ids! + Rails.logger.debug("[EVIL-QUERY] aspect_post_ids!") @user.visible_shareable_ids(Post, :limit => 15, :order => "#{@order} DESC", :max_time => @max_time, :all_aspects? => true, :by_members_of => @user.aspect_ids) end def followed_tags_posts! + Rails.logger.debug("[EVIL-QUERY] followed_tags_posts!") StatusMessage.public_tag_stream(@user.followed_tag_ids) end def mentioned_posts + Rails.logger.debug("[EVIL-QUERY] mentioned_posts") StatusMessage.where_person_is_mentioned(@user.person) end