summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/helpers/twitter_helper.rb18
1 files changed, 17 insertions, 1 deletions
diff --git a/app/helpers/twitter_helper.rb b/app/helpers/twitter_helper.rb
index 1081c05..035d75c 100644
--- a/app/helpers/twitter_helper.rb
+++ b/app/helpers/twitter_helper.rb
@@ -15,8 +15,24 @@ module TwitterHelper
Rails.application.secrets.twitter['twitter_handle']
end
+ def twitter_user_info
+ $twitter_user_info ||= []
+ end
+
def twitter_name
- twitter_client.user(twitter_handle).name
+ if twitter_user_info[0] == nil
+ update_twitter_info
+ else
+ if Time.now > twitter_user_info[0] + 15.minutes
+ update_twitter_info
+ end
+ end
+ twitter_user_info[1]
+ end
+
+ def update_twitter_info
+ twitter_user_info[0] = Time.now
+ twitter_user_info[1] = twitter_client.user(twitter_handle).name
end
def tweets