cache artist domains, show artist domains in wiki excerpt on post listing
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user