favgroups: optimize favgroup:<name> search metatag.

The previous method resulted in a `WHERE posts.id IN (<list of ids>)`
clause, which turned into a huge list when the favgroup had a lot of
posts.
This commit is contained in:
evazion
2020-01-17 13:38:51 -06:00
parent e6ffdfdf81
commit 20f893161b

View File

@@ -451,11 +451,11 @@ class PostQueryBuilder
end
q[:favgroups_neg].to_a.each do |favgroup|
relation = relation.where.not("posts.id": favgroup.post_ids)
relation = relation.where.not(id: FavoriteGroup.where(id: favgroup.id).select("unnest(post_ids)"))
end
q[:favgroups].to_a.each do |favgroup|
relation = relation.where("posts.id": favgroup.post_ids)
relation = relation.where(id: FavoriteGroup.where(id: favgroup.id).select("unnest(post_ids)"))
end
if q[:upvote].present?