artists: reduce queries in artist summaries.

Avoid a few queries when searching for single artist tags.
This commit is contained in:
evazion
2019-09-05 00:00:15 -05:00
parent 416f817f6d
commit fc3b822bdf
3 changed files with 2 additions and 28 deletions

View File

@@ -386,14 +386,6 @@ class Artist < ApplicationRecord
end
module TagMethods
def has_tag_alias?
TagAlias.active.exists?(["antecedent_name = ?", name])
end
def tag_alias_name
TagAlias.active.find_by_antecedent_name(name).consequent_name
end
def category_name
Tag.category_for(name)
end

View File

@@ -3,16 +3,13 @@
<li><strong>Status</strong> <%= artist.status %></li>
<% if !artist.is_banned? || CurrentUser.is_member? %>
<% if artist.has_tag_alias? %>
<li><strong>Tag Alias</strong> <%= artist.tag_alias_name %></li>
<% end %>
<% if artist.other_names.present? %>
<li><strong>Other Names</strong> <%= link_to_artists(artist.other_names) %></li>
<% end %>
<% if artist.group_name.present? %>
<li><strong>Group</strong> <%= link_to_artist(artist.group_name) %></li>
<% end %>
<% if artist.members.any? %>
<% if artist.members.present? %>
<li><strong>Members</strong> <%= link_to_artists(artist.members.map(&:name)) %></li>
<% end %>
<% if artist.domains.any? %>
@@ -23,7 +20,7 @@
<% end %>
</ul>
<% end %>
<% if artist.urls.any? %>
<% if artist.urls.present? %>
<li><strong>URLs</strong></li>
<ul>
<% artist.urls.each do |url| %>