Fix #5215: Using the full rating name in /ai_tags shows no results

This commit is contained in:
evazion
2022-06-27 01:54:46 -05:00
parent 04359d67f4
commit a2d8d19625

View File

@@ -7,11 +7,16 @@ class AITag < ApplicationRecord
validates :score, inclusion: { in: (0.0..1.0) }
def self.named(name)
name = $1.downcase if name =~ /\A(rating:.)/i
where(tag: Tag.find_by_name_or_alias(name))
end
def self.search(params)
q = search_attributes(params, :media_asset, :tag, :post, :score)
if params[:tag_name].present?
q = q.where(tag_id: Tag.find_by_name_or_alias(params[:tag_name])&.id)
q = q.named(params[:tag_name])
end
if params[:is_posted].to_s.truthy?