From 1552c4b69e35b629d32db618b916ea0c056b20a1 Mon Sep 17 00:00:00 2001 From: Neil Lalonde Date: Fri, 2 Aug 2013 16:37:24 -0400 Subject: [PATCH] Remove users column from Top Traffic Sources table on dashboard. It's not useful and very expensive to calculate. --- .../javascripts/admin/templates/dashboard.js.handlebars | 2 -- app/models/incoming_links_report.rb | 8 +------- spec/models/incoming_links_report_spec.rb | 5 ++--- 3 files changed, 3 insertions(+), 12 deletions(-) diff --git a/app/assets/javascripts/admin/templates/dashboard.js.handlebars b/app/assets/javascripts/admin/templates/dashboard.js.handlebars index a3c5c2bd0..7c90503fd 100644 --- a/app/assets/javascripts/admin/templates/dashboard.js.handlebars +++ b/app/assets/javascripts/admin/templates/dashboard.js.handlebars @@ -236,7 +236,6 @@ {{top_traffic_sources.title}} ({{i18n admin.dashboard.reports.last_30_days}}) {{top_traffic_sources.ytitles.num_clicks}} {{top_traffic_sources.ytitles.num_topics}} - {{top_traffic_sources.ytitles.num_users}} {{#unless loading}} @@ -246,7 +245,6 @@ {{domain}} {{num_clicks}} {{num_topics}} - {{num_users}} {{/each}} diff --git a/app/models/incoming_links_report.rb b/app/models/incoming_links_report.rb index 77129ec89..35c0bcfff 100644 --- a/app/models/incoming_links_report.rb +++ b/app/models/incoming_links_report.rb @@ -63,10 +63,9 @@ class IncomingLinksReport num_clicks = link_count_per_domain num_topics = topic_count_per_domain(num_clicks.keys) - num_users = user_count_per_domain(num_clicks.keys) report.data = [] num_clicks.keys.each do |domain| - report.data << {domain: domain, num_clicks: num_clicks[domain], num_topics: num_topics[domain], num_users: num_users[domain]} + report.data << {domain: domain, num_clicks: num_clicks[domain], num_topics: num_topics[domain]} end report.data = report.data.sort_by {|x| x[:num_clicks]}.reverse[0,10] end @@ -84,11 +83,6 @@ class IncomingLinksReport per_domain(domains).count('topic_id', distinct: true) end - def self.user_count_per_domain(domains) - # COUNT(DISTINCT) is slow - per_domain(domains).count('user_id', distinct: true) - end - def self.report_top_referred_topics(report) report.y_titles[:num_clicks] = I18n.t("reports.#{report.type}.num_clicks") diff --git a/spec/models/incoming_links_report_spec.rb b/spec/models/incoming_links_report_spec.rb index 5970589e1..6c5e7952f 100644 --- a/spec/models/incoming_links_report_spec.rb +++ b/spec/models/incoming_links_report_spec.rb @@ -59,9 +59,8 @@ describe IncomingLinksReport do it 'with some IncomingLink records, it returns correct data' do IncomingLinksReport.stubs(:link_count_per_domain).returns({'twitter.com' => 8, 'facebook.com' => 3}) IncomingLinksReport.stubs(:topic_count_per_domain).returns({'twitter.com' => 2, 'facebook.com' => 3}) - IncomingLinksReport.stubs(:user_count_per_domain).returns({'twitter.com' => 4, 'facebook.com' => 1}) - top_traffic_sources[:data][0].should == {domain: 'twitter.com', num_clicks: 8, num_topics: 2, num_users: 4} - top_traffic_sources[:data][1].should == {domain: 'facebook.com', num_clicks: 3, num_topics: 3, num_users: 1} + top_traffic_sources[:data][0].should == {domain: 'twitter.com', num_clicks: 8, num_topics: 2} + top_traffic_sources[:data][1].should == {domain: 'facebook.com', num_clicks: 3, num_topics: 3} end end