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:
evazion
2022-07-02 19:05:12 -05:00
parent 483f311428
commit 9000fa63bc
4 changed files with 20 additions and 4 deletions

View File

@@ -58,7 +58,11 @@ class RelatedTagQuery
def ai_tags
return AITag.none if media_asset.nil?
media_asset.ai_tags.joins(:tag).undeprecated.nonempty.in_order_of(:"tags.category", TagCategory.canonical_mapping.values).order("ai_tags.score DESC, tags.name ASC").take(limit)
tags = media_asset.ai_tags.includes(:tag, :aliased_tag)
tags = tags.reject(&:is_deprecated?).reject { |t| t.empty? && !t.metatag? }
tags = tags.sort_by { |t| [TagCategory.canonical_mapping.keys.index(t.category_name), -t.score, t.name] }
tags.take(limit)
end
# Returns the top 20 most frequently added tags within the last 20 edits made by the user in the last hour.