use Sources::Site to look up artists by profile page

This commit is contained in:
r888888888
2015-02-14 23:30:05 -08:00
parent 3c7466e6b8
commit f38cf1526c

View File

@@ -309,11 +309,25 @@ class Artist < ActiveRecord::Base
if matches.any?
where("id in (?)", matches)
elsif matches = search_for_profile(string)
where("id in (?)", matches)
else
where("false")
end
end
def search_for_profile(url)
source = Sources::Site.new(url)
if source.strategy
source.get
find_all_by_url(source.profile_url)
else
nil
end
rescue
nil
end
def other_names_match(string)
if string =~ /\*/ && CurrentUser.user.is_builder?
where("other_names ILIKE ? ESCAPE E'\\\\'", string.to_escaped_for_sql_like)