Updating queries for the stream to be faster
This commit is contained in:
parent
b5e6c2a149
commit
c8a0c81b6a
3 changed files with 7 additions and 5 deletions
|
|
@ -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])
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue