artists/summary: remove list of top source domains.

Remove the list of most-used source domains from artist summaries. This
took up a lot of space and usually wasn't very useful. It was also slow.
We had to calculate this on every artist tag search so we could display
it in the Artist tab, even though usually the user didn't open the tab.
This commit is contained in:
evazion
2020-02-08 18:42:25 -06:00
parent 3ef4d9c7ac
commit a6f11610bd
2 changed files with 0 additions and 37 deletions

View File

@@ -170,10 +170,6 @@ class Artist < ApplicationRecord
end end
end end
included do
memoize :domains
end
def sorted_urls def sorted_urls
urls.sort {|a, b| a.priority <=> b.priority} urls.sort {|a, b| a.priority <=> b.priority}
end end
@@ -200,31 +196,6 @@ class Artist < ApplicationRecord
def clear_url_string_changed def clear_url_string_changed
self.url_string_changed = false self.url_string_changed = false
end end
def map_domain(x)
case x
when "pximg.net"
"pixiv.net"
when "deviantart.net"
"deviantart.com"
else
x
end
end
def domains
Cache.get("artist-domains-#{id}", 1.day) do
domains = Post.raw_tag_match(name).pluck(:source).map do |x|
map_domain(Addressable::URI.parse(x).domain)
rescue Addressable::URI::InvalidURIError
nil
end
domains.compact.inject(Hash.new(0)) {|h, x| h[x] += 1; h}.sort {|a, b| b[1] <=> a[1]}
end
end
end end
module NameMethods module NameMethods

View File

@@ -24,14 +24,6 @@
<% end %> <% end %>
</li> </li>
<% end %> <% end %>
<% if artist.domains.any? %>
<li><strong>Domains</strong></li>
<ul class="list-bulleted">
<% artist.domains.each do |url, count| %>
<li><%= url %>: <%= count %></li>
<% end %>
</ul>
<% end %>
<% if artist.urls.present? %> <% if artist.urls.present? %>
<li><strong>URLs</strong></li> <li><strong>URLs</strong></li>
<ul> <ul>