From a6f11610bd8afafdee48d5e87fd550a5a5bfbbf1 Mon Sep 17 00:00:00 2001 From: evazion Date: Sat, 8 Feb 2020 18:42:25 -0600 Subject: [PATCH] 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. --- app/models/artist.rb | 29 ----------------------------- app/views/artists/_summary.html.erb | 8 -------- 2 files changed, 37 deletions(-) diff --git a/app/models/artist.rb b/app/models/artist.rb index c6f6c69f1..2c70a6573 100644 --- a/app/models/artist.rb +++ b/app/models/artist.rb @@ -170,10 +170,6 @@ class Artist < ApplicationRecord end end - included do - memoize :domains - end - def sorted_urls urls.sort {|a, b| a.priority <=> b.priority} end @@ -200,31 +196,6 @@ class Artist < ApplicationRecord def clear_url_string_changed self.url_string_changed = false 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 module NameMethods diff --git a/app/views/artists/_summary.html.erb b/app/views/artists/_summary.html.erb index c75ca3aba..2e8270ac9 100644 --- a/app/views/artists/_summary.html.erb +++ b/app/views/artists/_summary.html.erb @@ -24,14 +24,6 @@ <% end %> <% end %> - <% if artist.domains.any? %> -
  • Domains
  • - - <% end %> <% if artist.urls.present? %>
  • URLs