sources: simplify artist finder url normalization.

Get rid of `normalized_for_artist_finder?` and `normalizable_for_artist_finder?`.
This was legacy bullshit that was originally designed to avoid API calls
when saving artist entries containing old Pixiv direct image urls that
had already been normalized, or that couldn't be normalized because they
were bad id.

Nowadays we store profile urls in artist entries instead of direct image
urls, so we don't normally need to do any API calls to normalize the
profile url. Strategies should take care to avoid triggering API calls
inside `profile_url` when possible.
This commit is contained in:
evazion
2020-05-29 11:49:22 -05:00
parent 9ba6d60ad3
commit 88d9fc4e5e
10 changed files with 2 additions and 103 deletions

View File

@@ -33,16 +33,7 @@ class ArtistUrl < ApplicationRecord
# the strategy won't always work for twitter because it looks for a status
url = url.downcase if url =~ %r!^https?://(?:mobile\.)?twitter\.com!
begin
source = Sources::Strategies.find(url)
if !source.normalized_for_artist_finder? && source.normalizable_for_artist_finder?
url = source.normalize_for_artist_finder
end
rescue Net::OpenTimeout, PixivApiClient::Error
raise if Rails.env.test?
end
url = Sources::Strategies.find(url).normalize_for_artist_finder
url = url.gsub(/\/+\Z/, "")
url = url.gsub(%r!^https://!, "http://")
url + "/"