tags: exclude deprecated tags from related tags list.
Don't show deprecated tags in the related tags or translated tags lists when editing a post. It doesn't make sense to recommended adding tags that can't be added to the post.
This commit is contained in:
@@ -59,7 +59,7 @@ module RelatedTagCalculator
|
|||||||
|
|
||||||
tags = Tag.from(tag_counts).joins("JOIN tags ON tags.name = tag")
|
tags = Tag.from(tag_counts).joins("JOIN tags ON tags.name = tag")
|
||||||
tags = tags.select("tags.*, overlap_count")
|
tags = tags.select("tags.*, overlap_count")
|
||||||
tags = tags.where("tags.post_count > 0")
|
tags = tags.nonempty.undeprecated
|
||||||
tags = tags.where(category: category) if category.present?
|
tags = tags.where(category: category) if category.present?
|
||||||
tags = tags.order("overlap_count DESC, tags.post_count DESC, tags.name")
|
tags = tags.order("overlap_count DESC, tags.post_count DESC, tags.name")
|
||||||
tags
|
tags
|
||||||
|
|||||||
@@ -227,7 +227,7 @@ module Source
|
|||||||
|
|
||||||
def translated_tags
|
def translated_tags
|
||||||
translated_tags = normalized_tags.flat_map(&method(:translate_tag)).uniq.sort
|
translated_tags = normalized_tags.flat_map(&method(:translate_tag)).uniq.sort
|
||||||
translated_tags.reject(&:artist?)
|
translated_tags.reject(&:artist?).reject(&:is_deprecated?)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Given a tag from the source site, should return an array of corresponding Danbooru tags.
|
# Given a tag from the source site, should return an array of corresponding Danbooru tags.
|
||||||
|
|||||||
@@ -22,6 +22,8 @@ class Tag < ApplicationRecord
|
|||||||
|
|
||||||
scope :empty, -> { where("tags.post_count <= 0") }
|
scope :empty, -> { where("tags.post_count <= 0") }
|
||||||
scope :nonempty, -> { where("tags.post_count > 0") }
|
scope :nonempty, -> { where("tags.post_count > 0") }
|
||||||
|
scope :deprecated, -> { where(is_deprecated: true) }
|
||||||
|
scope :undeprecated, -> { where(is_deprecated: false) }
|
||||||
|
|
||||||
module ApiMethods
|
module ApiMethods
|
||||||
def to_legacy_json
|
def to_legacy_json
|
||||||
|
|||||||
@@ -206,7 +206,7 @@ class WikiPage < ApplicationRecord
|
|||||||
|
|
||||||
def tags
|
def tags
|
||||||
titles = DText.parse_wiki_titles(body).uniq
|
titles = DText.parse_wiki_titles(body).uniq
|
||||||
tags = Tag.nonempty.where(name: titles).pluck(:name)
|
tags = Tag.nonempty.undeprecated.where(name: titles).pluck(:name)
|
||||||
tags += TagAlias.active.where(antecedent_name: titles).pluck(:antecedent_name)
|
tags += TagAlias.active.where(antecedent_name: titles).pluck(:antecedent_name)
|
||||||
TagAlias.to_aliased(titles & tags)
|
TagAlias.to_aliased(titles & tags)
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user