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
|
end
|
||||||
|
|
||||||
def construct_public_followings_sql(opts)
|
def construct_public_followings_sql(opts)
|
||||||
aspects = Aspect.where(:id => opts[:by_members_of])
|
Rails.logger.debug("[EVIL-QUERY] user.construct_public_followings_sql")
|
||||||
person_ids = Person.connection.select_values(people_in_aspects(aspects).select("people.id").to_sql)
|
query = opts[:klass].where(:author_id => Person.in_aspects(opts[:by_members_of]).select("people.id"), :public => true, :pending => false)
|
||||||
|
|
||||||
query = opts[:klass].where(:author_id => person_ids, :public => true, :pending => false)
|
|
||||||
|
|
||||||
unless(opts[:klass] == Photo)
|
unless(opts[:klass] == Photo)
|
||||||
query = query.where(:type => opts[:type])
|
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
|
# Log the query plan for queries taking more than this (works
|
||||||
# with SQLite, MySQL, and PostgreSQL)
|
# 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
|
# Do not compress assets
|
||||||
config.assets.compress = false
|
config.assets.compress = false
|
||||||
|
|
|
||||||
|
|
@ -51,20 +51,24 @@ module EvilQuery
|
||||||
end
|
end
|
||||||
|
|
||||||
def make_relation!
|
def make_relation!
|
||||||
|
Rails.logger.debug("[EVIL-QUERY] make_relation!")
|
||||||
post_ids = aspects_post_ids! + ids!(followed_tags_posts!) + ids!(mentioned_posts)
|
post_ids = aspects_post_ids! + ids!(followed_tags_posts!) + ids!(mentioned_posts)
|
||||||
post_ids += ids!(community_spotlight_posts!) if @include_spotlight
|
post_ids += ids!(community_spotlight_posts!) if @include_spotlight
|
||||||
Post.where(:id => post_ids)
|
Post.where(:id => post_ids)
|
||||||
end
|
end
|
||||||
|
|
||||||
def aspects_post_ids!
|
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)
|
@user.visible_shareable_ids(Post, :limit => 15, :order => "#{@order} DESC", :max_time => @max_time, :all_aspects? => true, :by_members_of => @user.aspect_ids)
|
||||||
end
|
end
|
||||||
|
|
||||||
def followed_tags_posts!
|
def followed_tags_posts!
|
||||||
|
Rails.logger.debug("[EVIL-QUERY] followed_tags_posts!")
|
||||||
StatusMessage.public_tag_stream(@user.followed_tag_ids)
|
StatusMessage.public_tag_stream(@user.followed_tag_ids)
|
||||||
end
|
end
|
||||||
|
|
||||||
def mentioned_posts
|
def mentioned_posts
|
||||||
|
Rails.logger.debug("[EVIL-QUERY] mentioned_posts")
|
||||||
StatusMessage.where_person_is_mentioned(@user.person)
|
StatusMessage.where_person_is_mentioned(@user.person)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue