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:
@@ -12,15 +12,16 @@ class DtextLink < ApplicationRecord
|
||||
|
||||
scope :wiki_page, -> { where(model_type: "WikiPage") }
|
||||
scope :forum_post, -> { where(model_type: "ForumPost") }
|
||||
scope :pool, -> { where(model_type: "Pool") }
|
||||
|
||||
def self.visible(user)
|
||||
# XXX the double negation is to prevent postgres from choosing a bad query
|
||||
# plan (it doesn't know that most forum posts aren't mod-only posts).
|
||||
wiki_page.or(forum_post.where.not(model_id: ForumPost.not_visible(user)))
|
||||
wiki_page.or(forum_post.where.not(model_id: ForumPost.not_visible(user))).or(pool)
|
||||
end
|
||||
|
||||
def self.model_types
|
||||
%w[WikiPage ForumPost]
|
||||
%w[WikiPage ForumPost Pool]
|
||||
end
|
||||
|
||||
def self.new_from_dtext(dtext)
|
||||
|
||||
Reference in New Issue
Block a user