fixes #2993: Artist URL breakdown

This commit is contained in:
r888888888
2017-05-01 15:47:48 -07:00
parent d7e83bef79
commit 62c9beafc2
3 changed files with 44 additions and 6 deletions

View File

@@ -88,6 +88,23 @@ class Artist < ActiveRecord::Base
def url_string_changed?
url_string.scan(/\S+/) != url_array
end
def map_domain(x)
case x
when "pximg.net"
"pixiv.net"
when "deviantart.net"
"deviantart.com"
else
x
end
end
def domains
Post.raw_tag_match(name).pluck(:source).map {|x| map_domain(Addressable::URI.parse(x).domain)}.inject(Hash.new(0)) {|h, x| h[x] += 1; h}
end
end
module NameMethods
@@ -506,6 +523,10 @@ class Artist < ActiveRecord::Base
super + [:other_names_index]
end
def method_attributes
super + [:domains]
end
def legacy_api_hash
return {
:id => id,