Module: Adminpanel::AnalyticsHelper
- Defined in:
- app/helpers/adminpanel/analytics_helper.rb
Instance Method Summary collapse
- #days_to_substract ⇒ Object
- #exist_instagram_account? ⇒ Boolean
- #exist_twitter_account? ⇒ Boolean
- #fb_insights(fb_auth) ⇒ Object
- #insight ⇒ Object
- #metric(metric) ⇒ Object
- #tweet_link(tweet) ⇒ Object
Instance Method Details
#days_to_substract ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 |
# File 'app/helpers/adminpanel/analytics_helper.rb', line 4 def days_to_substract if params[:insight] == 'day' 1 elsif params[:insight] == 'week' 7 elsif params[:insight] == 'days_28' 28 else 0 end end |
#exist_instagram_account? ⇒ Boolean
39 40 41 42 43 44 45 |
# File 'app/helpers/adminpanel/analytics_helper.rb', line 39 def exist_instagram_account? if @instagram_token.nil? false else true end end |
#exist_twitter_account? ⇒ Boolean
47 48 49 50 51 52 53 |
# File 'app/helpers/adminpanel/analytics_helper.rb', line 47 def exist_twitter_account? if @twitter_token.nil? || @twitter_secret.nil? false else true end end |
#fb_insights(fb_auth) ⇒ Object
31 32 33 34 35 36 37 |
# File 'app/helpers/adminpanel/analytics_helper.rb', line 31 def fb_insights(fb_auth) if fb_auth "#{Koala::Facebook::API.new(fb_auth.value).get_object('me')['link']}insights" else '#' end end |
#insight ⇒ Object
16 17 18 19 20 21 |
# File 'app/helpers/adminpanel/analytics_helper.rb', line 16 def insight return 'day' if !params[:insight].present? return 'day' if params[:insight] == 'day' return 'week' if params[:insight] == 'week' return 'month' if params[:insight] == 'days_28' end |
#metric(metric) ⇒ Object
23 24 25 |
# File 'app/helpers/adminpanel/analytics_helper.rb', line 23 def metric(metric) metric.first['name'] end |
#tweet_link(tweet) ⇒ Object
27 28 29 |
# File 'app/helpers/adminpanel/analytics_helper.rb', line 27 def tweet_link(tweet) "http://www.twitter.com/#{tweet.user.screen_name}/status/#{tweet.id}" end |