From a2d8d196255198db86913afe04eaaabff1b16a34 Mon Sep 17 00:00:00 2001 From: evazion Date: Mon, 27 Jun 2022 01:54:46 -0500 Subject: [PATCH] Fix #5215: Using the full rating name in /ai_tags shows no results --- app/models/ai_tag.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/models/ai_tag.rb b/app/models/ai_tag.rb index b2db59c6c..103ca93fc 100644 --- a/app/models/ai_tag.rb +++ b/app/models/ai_tag.rb @@ -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?