pools: add ability to search for pools linking to given tag.
Add ability to search for pools linking to a given tag in the pool
description. Example:
https://danbooru.donmai.us/pools?search[linked_to]=touhou
(This isn't actually exposed in the UI to avoid cluttering the pool
search form with rarely used options.)
Pools with broken links can be found here:
https://danbooru.donmai.us/dtext_links?search[has_linked_tag]=No&search[has_linked_wiki]=No&search[model_type]=Pool
Lays the groundwork for fixing #4629.
This commit is contained in:
@@ -15,6 +15,7 @@ class Pool < ApplicationRecord
|
||||
after_save :create_version
|
||||
|
||||
deletable
|
||||
has_dtext_links :description
|
||||
|
||||
scope :series, -> { where(category: "series") }
|
||||
scope :collection, -> { where(category: "collection") }
|
||||
@@ -37,7 +38,7 @@ class Pool < ApplicationRecord
|
||||
end
|
||||
|
||||
def search(params)
|
||||
q = search_attributes(params, :id, :created_at, :updated_at, :is_deleted, :name, :description, :post_ids)
|
||||
q = search_attributes(params, :id, :created_at, :updated_at, :is_deleted, :name, :description, :post_ids, :dtext_links)
|
||||
q = q.text_attribute_matches(:description, params[:description_matches])
|
||||
|
||||
if params[:post_tags_match]
|
||||
@@ -48,6 +49,14 @@ class Pool < ApplicationRecord
|
||||
q = q.name_matches(params[:name_matches])
|
||||
end
|
||||
|
||||
if params[:linked_to].present?
|
||||
q = q.linked_to(params[:linked_to])
|
||||
end
|
||||
|
||||
if params[:not_linked_to].present?
|
||||
q = q.not_linked_to(params[:not_linked_to])
|
||||
end
|
||||
|
||||
case params[:category]
|
||||
when "series"
|
||||
q = q.series
|
||||
|
||||
Reference in New Issue
Block a user