Skip to content

Commit

Permalink
Merge pull request #623 from mlibrary/fixup/ga-limits-2
Browse files Browse the repository at this point in the history
hit the ga quota in a different way, expanding the exception handling
  • Loading branch information
sethaj authored Nov 17, 2016
2 parents 13682ef + f1e329b commit b1652d9
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions app/presenters/concerns/analytics_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,35 @@ module AnalyticsPresenter

def pageviews_by_path(path)
count = 0
profile = google_analytics_profile
if profile.present?
begin
begin
profile = google_analytics_profile
if profile.present?
Pageview.results(profile).each do |entry|
count += entry[:pageviews].to_i if entry[:pagePath] == path
end
rescue OAuth2::Error => e
Rails.logger.error(e.code["message"])
end
rescue OAuth2::Error => e
Rails.logger.error(e.code["message"])
end
return count
end

def pageviews_by_ids(ids)
count = 0
profile = google_analytics_profile
if profile.present?
begin
begin
profile = google_analytics_profile
if profile.present?
Pageview.results(profile).each do |entry|
ids.each do |id|
count += entry[:pageviews].to_i if entry[:pagePath].include? id
end
end
rescue OAuth2::Error => e
# TODO: we're hitting GA quotas for monograph_catalog pages in production.
# Need to figure out a better way to do this...
Rails.logger.error(e.code["message"])
return nil
end
rescue OAuth2::Error => e
# TODO: we're hitting GA quotas for monograph_catalog pages in production.
# Need to figure out a better way to do this...
Rails.logger.error(e.code["message"])
return nil
end
return count
end
Expand Down

0 comments on commit b1652d9

Please sign in to comment.