summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorthea <ta.kupler@gmail.com>2016-09-06 15:32:51 +0200
committerthea <ta.kupler@gmail.com>2016-09-06 15:32:51 +0200
commit6f255766d993672d8de17081fae4140564edb989 (patch)
tree5baeb159eff9f3546038ff93ff8046ea6145a9b8
parent3bfa7a6ff2f9fba98d7ece62859dfd7d83829fc1 (diff)
included extra methods to have the twitter call for twitter name only have happening at one place
-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