Use different user.construct_public_followings_sql query depending on database backend.
This is done for performance reasons as a temporary fix for problems with 0.4.0.0 on MySQL. This madness is explained in issue https://github.com/diaspora/diaspora/issues/5014.
This commit is contained in:
parent
c475a3985e
commit
80075c13f4
1 changed files with 10 additions and 1 deletions
|
|
@ -69,7 +69,16 @@ module User::Querying
|
||||||
|
|
||||||
def construct_public_followings_sql(opts)
|
def construct_public_followings_sql(opts)
|
||||||
Rails.logger.debug("[EVIL-QUERY] user.construct_public_followings_sql")
|
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)
|
|
||||||
|
# For PostgreSQL and MySQL/MariaDB we use a different query
|
||||||
|
# see issue: https://github.com/diaspora/diaspora/issues/5014
|
||||||
|
if AppConfig.postgres?
|
||||||
|
query = opts[:klass].where(:author_id => Person.in_aspects(opts[:by_members_of]).select("people.id"), :public => true, :pending => false)
|
||||||
|
else
|
||||||
|
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)
|
||||||
|
end
|
||||||
|
|
||||||
unless(opts[:klass] == Photo)
|
unless(opts[:klass] == Photo)
|
||||||
query = query.where(:type => opts[:type])
|
query = query.where(:type => opts[:type])
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue