artists: clean up artist finding logic.
Rename Artist#find_all_by_url to url_matches and drop previous url_matches method, along with find_artists and search_for_profile. Previously find_artists tried to lookup the url, referer url, and profile url in turn until an artist match was found. This was wasteful, because the source strategy already knows which url to lookup (usually the profile url). If that url doesn't find a match, then the artist doesn't exist.
This commit is contained in:
@@ -129,6 +129,8 @@ module Sources
|
||||
normalize_for_artist_finder.present?
|
||||
end
|
||||
|
||||
# The url to use for artist finding purposes. This will be stored in the
|
||||
# artist entry. Normally this will be the profile url.
|
||||
def normalize_for_artist_finder
|
||||
profile_url || url
|
||||
end
|
||||
@@ -139,8 +141,7 @@ module Sources
|
||||
end
|
||||
|
||||
def artists
|
||||
url = profile_url.presence || image_url.presence
|
||||
Artist.find_artists(url)
|
||||
Artist.url_matches(normalize_for_artist_finder)
|
||||
end
|
||||
|
||||
def file_url
|
||||
|
||||
@@ -66,14 +66,6 @@ module Sources::Strategies
|
||||
""
|
||||
end
|
||||
|
||||
def artists
|
||||
if profile_url.present?
|
||||
Artist.find_artists(profile_url)
|
||||
else
|
||||
[]
|
||||
end
|
||||
end
|
||||
|
||||
def artist_name
|
||||
return "" if api_response.blank?
|
||||
api_response.attrs[:user][:screen_name]
|
||||
|
||||
Reference in New Issue
Block a user