cache artist domains, show artist domains in wiki excerpt on post listing

This commit is contained in:
r888888888
2017-05-12 14:50:37 -07:00
parent bcec293efe
commit 5ad7f1af91
3 changed files with 90 additions and 66 deletions

View File

@@ -108,13 +108,15 @@ class Artist < ActiveRecord::Base
end
def domains
Post.raw_tag_match(name).pluck(:source).map do |x|
begin
map_domain(Addressable::URI.parse(x).domain)
rescue Addressable::URI::InvalidURIError
nil
end
end.compact.inject(Hash.new(0)) {|h, x| h[x] += 1; h}
Cache.get("artist-domains-#{id}", 1.day) do
Post.raw_tag_match(name).pluck(:source).map do |x|
begin
map_domain(Addressable::URI.parse(x).domain)
rescue Addressable::URI::InvalidURIError
nil
end
end.compact.inject(Hash.new(0)) {|h, x| h[x] += 1; h}.sort {|a, b| b[1] <=> a[1]}
end
end
end