fixes #2993: Artist URL breakdown
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user