ai tags: fix N+1 query issue.

This commit is contained in:
evazion
2022-06-27 02:37:49 -05:00
parent a2d8d19625
commit 6a08c57cec
3 changed files with 7 additions and 6 deletions

View File

@@ -47,12 +47,12 @@ class AITag < ApplicationRecord
# True if the AI tag is present on the post; false if the AI tag is not on the post, or the asset isn't a post yet.
def post_tagged?
if post.nil?
if media_asset.post.nil?
false
elsif tag.name =~ /\Arating:(.)\z/
post.rating == $1
media_asset.post.rating == $1
else
post.has_tag?(tag.name)
media_asset.post.has_tag?(tag.name)
end
end