Finalize new analytics style (#1117)
This commit is contained in:
parent
c5807205b5
commit
61173bede1
4 changed files with 11 additions and 10 deletions
|
|
@ -17,7 +17,7 @@ class GoogleAnalytics
|
|||
def get_pageviews
|
||||
requests = @article_ids.map do |id|
|
||||
article = Article.find_by_id(id)
|
||||
make_report_request("ga:pagePath==#{article.path}", "ga:pageviews")
|
||||
make_report_request("ga:pagePath=@#{article.slug}", "ga:pageviews")
|
||||
end
|
||||
pageviews = fetch_all_results(requests)
|
||||
@article_ids.zip(pageviews).to_h
|
||||
|
|
@ -82,4 +82,4 @@ class GoogleAnalytics
|
|||
scope: [AUTH_ANALYTICS_READONLY],
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,4 +1,8 @@
|
|||
class ArticleAnalyticsFetcher
|
||||
def initialize(context = "default")
|
||||
@context = context
|
||||
end
|
||||
|
||||
def update_analytics(user_id)
|
||||
articles_to_check = Article.where(user_id: user_id, published: true)
|
||||
qualified_articles = get_articles_that_qualify(articles_to_check)
|
||||
|
|
@ -29,6 +33,7 @@ class ArticleAnalyticsFetcher
|
|||
end
|
||||
|
||||
def should_fetch(article)
|
||||
return true if @context == "force"
|
||||
article.positive_reactions_count > article.previous_positive_reactions_count
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
<a href="<%= article.path %>/delete_confirm" data-no-instant class="cta pill black">DELETE</a>
|
||||
<% if article.published && current_user.can_view_analytics? %>
|
||||
<span id="pageviews-<%= article.id %>" class="cta pill dashboard-pageviews-indicator" data-analytics-pageviews data-article-id="<%= article.id %>">
|
||||
<%= article.page_views_count > 100 ? article.page_views_count : "under 100" %> views // <%= article.positive_reactions_count %> reactions
|
||||
<%= article.page_views_count > 100 ? article.page_views_count : "under 100" %> views // <%= article.positive_reactions_count %> reactions // <%= article.comments_count %> comments
|
||||
</span>
|
||||
<% end %>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -27,9 +27,7 @@
|
|||
</h1>
|
||||
<% end %>
|
||||
<% if @user.org_admin && @user.organization && params[:which] == "organization" %>
|
||||
<% if current_user.can_view_analytics? %>
|
||||
<%= render "analytics" %>
|
||||
<% end %>
|
||||
<%= render "analytics" %>
|
||||
<% @articles.each do |article| %>
|
||||
<%= render "dashboard_article", article: article, org_admin: true %>
|
||||
<% end %>
|
||||
|
|
@ -50,9 +48,7 @@
|
|||
<% end %>
|
||||
<% end %>
|
||||
<% elsif @articles.any? %>
|
||||
<% if current_user.can_view_analytics? %>
|
||||
<%= render "analytics" %>
|
||||
<% end %>
|
||||
<%= render "analytics" %>
|
||||
<% if current_user.has_role?(:video_permission) %>
|
||||
<a class="video-upload-cta" href="/videos/new" data-no-instant>
|
||||
Upload a Video 🎥
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue