Merge pull request #3886 from r888888888/source-api-caching
cache api clients
This commit is contained in:
@@ -123,7 +123,7 @@ module Sources
|
||||
public
|
||||
|
||||
def api_client
|
||||
NicoSeigaApiClient.new(illust_id)
|
||||
NicoSeigaApiClient.new(illust_id: illust_id)
|
||||
end
|
||||
memoize :api_client
|
||||
|
||||
|
||||
@@ -53,13 +53,17 @@ module Sources::Strategies
|
||||
end
|
||||
|
||||
def profile_url
|
||||
if url =~ %r{\Ahttps?://(?:mobile\.)?twitter\.com/(\w+)}i && $1 != "i"
|
||||
"https://twitter.com/#{$1}"
|
||||
elsif artist_name.present?
|
||||
"https://twitter.com/" + artist_name
|
||||
else
|
||||
""
|
||||
if url =~ %r{\Ahttps?://(?:mobile\.)?twitter\.com/(\w+)}i
|
||||
if $1 != "i"
|
||||
return "https://twitter.com/#{$1}"
|
||||
end
|
||||
end
|
||||
|
||||
if artist_name.present?
|
||||
return "https://twitter.com/" + artist_name
|
||||
end
|
||||
|
||||
""
|
||||
end
|
||||
|
||||
def artists
|
||||
@@ -129,7 +133,7 @@ module Sources::Strategies
|
||||
memoize :service
|
||||
|
||||
def api_response
|
||||
service.client.status(status_id, tweet_mode: "extended")
|
||||
service.status(status_id, tweet_mode: "extended")
|
||||
rescue ::Twitter::Error::NotFound
|
||||
{}
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user