related tags: fix AI tags not showing rating tags.
* Fix the suggested tags list in the related tags box not showing rating tags. * Fix the suggested tags list showing tags that have been aliased to another tag.
This commit is contained in:
@@ -6,6 +6,7 @@ class AITag < ApplicationRecord
|
||||
belongs_to :tag
|
||||
belongs_to :media_asset
|
||||
has_one :post, through: :media_asset
|
||||
has_one :aliased_tag, through: :tag
|
||||
|
||||
validates :score, inclusion: { in: (0..100) }
|
||||
|
||||
@@ -14,7 +15,7 @@ class AITag < ApplicationRecord
|
||||
scope :empty, -> { where(tag: Tag.empty) }
|
||||
scope :nonempty, -> { where(tag: Tag.nonempty) }
|
||||
|
||||
delegate :name, :pretty_name, :post_count, :category, :category_name, to: :tag
|
||||
delegate :name, :pretty_name, :post_count, :category, :category_name, :is_deprecated?, :empty?, :is_aliased?, :metatag?, to: :tag
|
||||
|
||||
def self.named(name)
|
||||
name = $1.downcase if name =~ /\A(rating:.)/i
|
||||
|
||||
@@ -9,6 +9,7 @@ class Tag < ApplicationRecord
|
||||
has_one :wiki_page, :foreign_key => "title", :primary_key => "name"
|
||||
has_one :artist, :foreign_key => "name", :primary_key => "name"
|
||||
has_one :antecedent_alias, -> {active}, :class_name => "TagAlias", :foreign_key => "antecedent_name", :primary_key => "name"
|
||||
has_one :aliased_tag, through: :antecedent_alias, source: :consequent_tag
|
||||
has_many :consequent_aliases, -> {active}, :class_name => "TagAlias", :foreign_key => "consequent_name", :primary_key => "name"
|
||||
has_many :antecedent_implications, -> {active}, :class_name => "TagImplication", :foreign_key => "antecedent_name", :primary_key => "name"
|
||||
has_many :consequent_implications, -> {active}, :class_name => "TagImplication", :foreign_key => "consequent_name", :primary_key => "name"
|
||||
@@ -405,6 +406,14 @@ class Tag < ApplicationRecord
|
||||
end
|
||||
end
|
||||
|
||||
def is_aliased?
|
||||
aliased_tag.present?
|
||||
end
|
||||
|
||||
def metatag?
|
||||
name.match?(/\A#{PostQueryBuilder::METATAGS.join("|")}:/i)
|
||||
end
|
||||
|
||||
def self.model_restriction(table)
|
||||
super.where(table[:post_count].gt(0))
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user