aliases/implications: change automatic retirement rules.

Change the rules for automatically retiring aliases and implications:

* Retire aliases to tags that are empty, or that are for a general or
  artist tag that hasn't received any new posts in the last two years.
* Retire implications from tags that are empty.
* Don't retire aliases or implications for character, copyright, or
  meta tags any more, unless the tags are empty.
This commit is contained in:
evazion
2021-11-05 05:46:50 -05:00
parent 65ab7f1eb5
commit a5f589f9e0
6 changed files with 136 additions and 92 deletions

View File

@@ -6,6 +6,8 @@ class TagAlias < TagRelationship
before_create :delete_conflicting_relationships
scope :empty, -> { joins(:consequent_tag).merge(Tag.empty) }
def self.to_aliased(names)
names = Array(names).map(&:to_s)
return [] if names.empty?

View File

@@ -15,6 +15,8 @@ class TagImplication < TagRelationship
validate :meets_tag_size_requirements, on: :request
validate :has_wiki_page, on: :request
scope :empty, -> { joins(:antecedent_tag).merge(Tag.empty) }
concerning :HierarchyMethods do
class_methods do
def ancestors_of(names)

View File

@@ -16,6 +16,12 @@ class TagRelationship < ApplicationRecord
scope :deleted, -> {where(status: "deleted")}
scope :retired, -> {where(status: "retired")}
# TagAlias.artist, TagAlias.general, TagAlias.character, TagAlias.copyright, TagAlias.meta
# TagImplication.artist, TagImplication.general, TagImplication.character, TagImplication.copyright, TagImplication.meta
TagCategory.categories.each do |category|
scope category, -> { joins(:consequent_tag).where(consequent_tag: { category: TagCategory.mapping[category] }) }
end
before_validation :normalize_names
validates :status, inclusion: { in: STATUSES }
validates :antecedent_name, presence: true
@@ -103,10 +109,6 @@ class TagRelationship < ApplicationRecord
# "TagAlias" -> "tag alias", "TagImplication" -> "tag implication"
self.class.name.underscore.tr("_", " ")
end
def retirement_message
"The #{relationship} [[#{antecedent_name}]] -> [[#{consequent_name}]] has been retired."
end
end
def antecedent_and_consequent_are_different