Mercurial > rsstweet
diff app/models/tweet.rb @ 134:3646b3e319c7
Only try/catch the tweet downloading part
author | nanaya <me@nanaya.pro> |
---|---|
date | Wed, 13 Dec 2017 02:28:34 +0900 |
parents | 8b2d770160e3 |
children | 3fc882b0884d |
line wrap: on
line diff
--- a/app/models/tweet.rb Sat Dec 09 20:13:24 2017 +0900 +++ b/app/models/tweet.rb Wed Dec 13 02:28:34 2017 +0900 @@ -6,21 +6,21 @@ def timeline start_client_config_id = @client_config_id - begin - @timeline ||= - Rails.cache.fetch({ :timeline => @twitter_id }, :expires_in => cache_expires_time) do + @timeline ||= + Rails.cache.fetch({ :timeline => @twitter_id }, :expires_in => cache_expires_time) do + begin @client.user_timeline(@twitter_id, :count => 100, :exclude_replies => false, :include_rts => true, :tweet_mode => :extended) + rescue Twitter::Error::TooManyRequests + next_client_config_id = @client_config_id + 1 + init_client next_client_config_id + + if @client_config_id == start_client_config_id + raise + else + retry + end end - rescue Twitter::Error::TooManyRequests - next_client_config_id = @client_config_id + 1 - init_client next_client_config_id - - if @client_config_id == start_client_config_id - raise - else - retry end - end end def user