Fix #3988: ordpool:<name> fails for large pools.
Also fixes ordpool:<name> not returning all posts in the correct order when searching for series pools that contain duplicate posts.
This commit is contained in:
@@ -406,7 +406,9 @@ class PostQueryBuilder
|
||||
|
||||
if q[:ordpool].present?
|
||||
pool_id = q[:ordpool].to_i
|
||||
relation = relation.find_ordered(Pool.find(pool_id).post_ids)
|
||||
|
||||
pool_posts = Pool.joins("CROSS JOIN unnest(pools.post_ids) WITH ORDINALITY AS row(post_id, pool_index)").where(id: pool_id).select(:post_id, :pool_index)
|
||||
relation = relation.joins("JOIN (#{pool_posts.to_sql}) pool_posts ON pool_posts.post_id = posts.id").order("pool_posts.pool_index ASC")
|
||||
end
|
||||
|
||||
if q[:favgroups_neg].present?
|
||||
|
||||
Reference in New Issue
Block a user