posts: stop using pool_string attribute.

Stop using the pool_string attribute on posts:

* Stop updating it when adding or removing posts from pools.
* Stop returning pool_string in the /posts.json API.
* Stop including the `data-pools` attribute on thumbnails.

The pool_string attribute was used in the past to facilitate pool:X
searches. Posts had a hidden pool_string attribute that contained a list
of every pool the post belonged to. These pools were treated like fake
hidden tags on the post and a search for `pool:X` was treated like a tag
search.

The pool_string has no longer been used for this purpose for a long time
now, and was only maintained for API compatibility purposes. Getting rid
of it eliminates a bunch of legacy cruft relating to adding and removing
posts from pools.

If you need to see which pools a post belongs to, do this:

* https://danbooru.donmai.us/pools.json?search[post_ids_include_any]=318550

The `data-pools` attribute on thumbnails was used by some people to add
custom borders to pooled posts with custom CSS. This will no longer
work. This was already broken because it included things like collection
pools and deleted pools, which you probably didn't want. Use a
userscript to add this attribute back to thumbnails if you need it.
This commit is contained in:
evazion
2021-10-07 05:55:43 -05:00
parent 595e02ab45
commit 7d503f088e
7 changed files with 13 additions and 161 deletions

View File

@@ -10,7 +10,6 @@ class Pool < ApplicationRecord
validate :updater_can_edit_deleted
before_validation :normalize_post_ids
before_validation :normalize_name
after_create :synchronize!
after_save :create_version
deletable
@@ -130,7 +129,7 @@ class Pool < ApplicationRecord
self.post_ids = version.post_ids
self.name = version.name
self.description = version.description
synchronize!
save!
end
def contains?(post_id)
@@ -161,7 +160,6 @@ class Pool < ApplicationRecord
with_lock do
update(post_ids: post_ids + [post.id])
post.add_pool!(self, true)
end
end
@@ -171,7 +169,6 @@ class Pool < ApplicationRecord
with_lock do
reload
update(post_ids: post_ids - [post.id])
post.remove_pool!(self)
end
end
@@ -181,29 +178,6 @@ class Pool < ApplicationRecord
Post.joins("JOIN (#{pool_posts.to_sql}) pool_posts ON pool_posts.post_id = posts.id").order("pool_posts.pool_index ASC")
end
def synchronize
post_ids_before = post_ids_before_last_save || post_ids_was
added = post_ids - post_ids_before
removed = post_ids_before - post_ids
added.each do |post_id|
post = Post.find(post_id)
post.add_pool!(self, true)
end
removed.each do |post_id|
post = Post.find(post_id)
post.remove_pool!(self)
end
normalize_post_ids
end
def synchronize!
synchronize
save if will_save_change_to_post_ids?
end
def post_count
post_ids.size
end