pools: stop using the pool_string field (#4160).

Stop using the pool_string field internally, but keep maintaining it
until we can drop it later.

* Stop using the pool_string for `pool:<name>` metatag searches.
* Stop using the pool_string in the `Post#pools` method. This is used to
  get the list of pools on post show pages.
This commit is contained in:
evazion
2019-09-06 22:03:40 -05:00
parent 3bd8a5c4e3
commit dc4d2e54b2
6 changed files with 69 additions and 42 deletions

View File

@@ -211,10 +211,38 @@ class PostQueryBuilder
end
end
if q[:pool] == "none"
relation = relation.where("posts.pool_string = ''")
elsif q[:pool] == "any"
relation = relation.where("posts.pool_string != ''")
q[:pool].to_a.each do |pool_name|
case pool_name
when "none"
relation = relation.where.not(id: Pool.select("unnest(post_ids)"))
when "any"
relation = relation.where(id: Pool.select("unnest(post_ids)"))
when "series"
relation = relation.where(id: Pool.series.select("unnest(post_ids)"))
when "collection"
relation = relation.where(id: Pool.collection.select("unnest(post_ids)"))
when /\*/
relation = relation.where(id: Pool.name_matches(pool_name).select("unnest(post_ids)"))
else
relation = relation.where(id: Pool.named(pool_name).select("unnest(post_ids)"))
end
end
q[:pool_neg].to_a.each do |pool_name|
case pool_name
when "none"
relation = relation.where(id: Pool.select("unnest(post_ids)"))
when "any"
relation = relation.where.not(id: Pool.select("unnest(post_ids)"))
when "series"
relation = relation.where.not(id: Pool.series.select("unnest(post_ids)"))
when "collection"
relation = relation.where.not(id: Pool.collection.select("unnest(post_ids)"))
when /\*/
relation = relation.where.not(id: Pool.name_matches(pool_name).select("unnest(post_ids)"))
else
relation = relation.where.not(id: Pool.named(pool_name).select("unnest(post_ids)"))
end
end
if q[:saved_searches]