From 69be7d0ad10b68ccc6924e07cb27e33a312c68b6 Mon Sep 17 00:00:00 2001 From: Neil Lalonde Date: Mon, 6 May 2013 11:56:35 -0400 Subject: [PATCH] Change the title Visits to Clicks in referral tables on admin dashboard --- .../admin/templates/dashboard.js.handlebars | 12 +++---- app/models/incoming_links_report.rb | 32 +++++++++---------- config/locales/server.en.yml | 6 ++-- spec/models/incoming_links_report_spec.rb | 18 +++++------ 4 files changed, 34 insertions(+), 34 deletions(-) diff --git a/app/assets/javascripts/admin/templates/dashboard.js.handlebars b/app/assets/javascripts/admin/templates/dashboard.js.handlebars index 28ef002137f..39d78e64ce0 100644 --- a/app/assets/javascripts/admin/templates/dashboard.js.handlebars +++ b/app/assets/javascripts/admin/templates/dashboard.js.handlebars @@ -176,7 +176,7 @@ {{top_referred_topics.title}} ({{i18n admin.dashboard.reports.last_30_days}}) - {{top_referred_topics.ytitles.num_visits}} + {{top_referred_topics.ytitles.num_clicks}} {{#unless loading}} @@ -184,7 +184,7 @@ {{shorten data.topic_title}} - {{data.num_visits}} + {{data.num_clicks}} {{/each}} @@ -197,7 +197,7 @@ {{top_traffic_sources.title}} ({{i18n admin.dashboard.reports.last_30_days}}) - {{top_traffic_sources.ytitles.num_visits}} + {{top_traffic_sources.ytitles.num_clicks}} {{top_traffic_sources.ytitles.num_topics}} {{top_traffic_sources.ytitles.num_users}} @@ -207,7 +207,7 @@ {{domain}} - {{num_visits}} + {{num_clicks}} {{num_topics}} {{num_users}} @@ -222,7 +222,7 @@ {{top_referrers.title}} ({{i18n admin.dashboard.reports.last_30_days}}) - {{top_referrers.ytitles.num_visits}} + {{top_referrers.ytitles.num_clicks}} {{top_referrers.ytitles.num_topics}} @@ -231,7 +231,7 @@ {{#linkTo adminUser username}}{{username}}{{/linkTo}} - {{num_visits}} + {{num_clicks}} {{num_topics}} diff --git a/app/models/incoming_links_report.rb b/app/models/incoming_links_report.rb index 026b7613cea..9060284dd8f 100644 --- a/app/models/incoming_links_report.rb +++ b/app/models/incoming_links_report.rb @@ -30,16 +30,16 @@ class IncomingLinksReport # Return top 10 users who brought traffic to the site within the last 30 days def self.report_top_referrers(report) - report.y_titles[:num_visits] = I18n.t("reports.#{report.type}.num_visits") + report.y_titles[:num_clicks] = I18n.t("reports.#{report.type}.num_clicks") report.y_titles[:num_topics] = I18n.t("reports.#{report.type}.num_topics") - num_visits = link_count_per_user + num_clicks = link_count_per_user num_topics = topic_count_per_user report.data = [] - num_visits.keys.each do |username| - report.data << {username: username, num_visits: num_visits[username], num_topics: num_topics[username]} + num_clicks.keys.each do |username| + report.data << {username: username, num_clicks: num_clicks[username], num_topics: num_topics[username]} end - report.data = report.data.sort_by {|x| x[:num_visits]}.reverse[0,10] + report.data = report.data.sort_by {|x| x[:num_clicks]}.reverse[0,10] end def self.per_user @@ -57,18 +57,18 @@ class IncomingLinksReport # Return top 10 domains that brought traffic to the site within the last 30 days def self.report_top_traffic_sources(report) - report.y_titles[:num_visits] = I18n.t("reports.#{report.type}.num_visits") + report.y_titles[:num_clicks] = I18n.t("reports.#{report.type}.num_clicks") report.y_titles[:num_topics] = I18n.t("reports.#{report.type}.num_topics") report.y_titles[:num_users] = I18n.t("reports.#{report.type}.num_users") - num_visits = link_count_per_domain + num_clicks = link_count_per_domain num_topics = topic_count_per_domain num_users = user_count_per_domain report.data = [] - num_visits.keys.each do |domain| - report.data << {domain: domain, num_visits: num_visits[domain], num_topics: num_topics[domain], num_users: num_users[domain]} + 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]} end - report.data = report.data.sort_by {|x| x[:num_visits]}.reverse[0,10] + report.data = report.data.sort_by {|x| x[:num_clicks]}.reverse[0,10] end def self.per_domain @@ -89,15 +89,15 @@ class IncomingLinksReport def self.report_top_referred_topics(report) - report.y_titles[:num_visits] = I18n.t("reports.#{report.type}.num_visits") - num_visits = link_count_per_topic - num_visits = num_visits.to_a.sort_by {|x| x[1]}.last(10).reverse # take the top 10 + report.y_titles[:num_clicks] = I18n.t("reports.#{report.type}.num_clicks") + num_clicks = link_count_per_topic + num_clicks = num_clicks.to_a.sort_by {|x| x[1]}.last(10).reverse # take the top 10 report.data = [] - topics = Topic.select('id, slug, title').where('id in (?)', num_visits.map {|z| z[0]}).all - num_visits.each do |topic_id, num_visits| + topics = Topic.select('id, slug, title').where('id in (?)', num_clicks.map {|z| z[0]}).all + num_clicks.each do |topic_id, num_clicks| topic = topics.find {|t| t.id == topic_id} if topic - report.data << {topic_id: topic_id, topic_title: topic.title, topic_slug: topic.slug, num_visits: num_visits} + report.data << {topic_id: topic_id, topic_title: topic.title, topic_slug: topic.slug, num_clicks: num_clicks} end end report.data diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml index e999f7b2e11..8a1e4c7f0d6 100644 --- a/config/locales/server.en.yml +++ b/config/locales/server.en.yml @@ -337,18 +337,18 @@ en: top_referrers: title: "Top Referrers" xaxis: "User" - num_visits: "Visits" + num_clicks: "Clicks" num_topics: "Topics" top_traffic_sources: title: "Top Traffic Sources" xaxis: "Domain" - num_visits: "Visits" + num_clicks: "Clicks" num_topics: "Topics" num_users: "Users" top_referred_topics: title: "Top Referred Topics" xaxis: "Topic" - num_visits: "Visits" + num_clicks: "Clicks" dashboard: rails_env_warning: "Your server is running in %{env} mode." diff --git a/spec/models/incoming_links_report_spec.rb b/spec/models/incoming_links_report_spec.rb index 69fa1b2b2da..5970589e168 100644 --- a/spec/models/incoming_links_report_spec.rb +++ b/spec/models/incoming_links_report_spec.rb @@ -15,7 +15,7 @@ describe IncomingLinksReport do top_referrers[:title].should be_present top_referrers[:xaxis].should be_present top_referrers[:ytitles].should be_present - top_referrers[:ytitles][:num_visits].should be_present + top_referrers[:ytitles][:num_clicks].should be_present top_referrers[:ytitles][:num_topics].should be_present end @@ -27,8 +27,8 @@ describe IncomingLinksReport do it 'with some IncomingLink records, it returns correct data' do IncomingLinksReport.stubs(:link_count_per_user).returns({'luke' => 4, 'chewie' => 2}) IncomingLinksReport.stubs(:topic_count_per_user).returns({'luke' => 2, 'chewie' => 1}) - top_referrers[:data][0].should == {username: 'luke', num_visits: 4, num_topics: 2} - top_referrers[:data][1].should == {username: 'chewie', num_visits: 2, num_topics: 1} + top_referrers[:data][0].should == {username: 'luke', num_clicks: 4, num_topics: 2} + top_referrers[:data][1].should == {username: 'chewie', num_clicks: 2, num_topics: 1} end end @@ -46,7 +46,7 @@ describe IncomingLinksReport do top_traffic_sources[:title].should be_present top_traffic_sources[:xaxis].should be_present top_traffic_sources[:ytitles].should be_present - top_traffic_sources[:ytitles][:num_visits].should be_present + top_traffic_sources[:ytitles][:num_clicks].should be_present top_traffic_sources[:ytitles][:num_topics].should be_present top_traffic_sources[:ytitles][:num_users].should be_present end @@ -60,8 +60,8 @@ describe IncomingLinksReport 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_visits: 8, num_topics: 2, num_users: 4} - top_traffic_sources[:data][1].should == {domain: 'facebook.com', num_visits: 3, num_topics: 3, num_users: 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} end end @@ -77,7 +77,7 @@ describe IncomingLinksReport do top_referred_topics[:title].should be_present top_referred_topics[:xaxis].should be_present top_referred_topics[:ytitles].should be_present - top_referred_topics[:ytitles][:num_visits].should be_present + top_referred_topics[:ytitles][:num_clicks].should be_present end it 'with no IncomingLink records, it returns correct data' do @@ -90,8 +90,8 @@ describe IncomingLinksReport do IncomingLinksReport.stubs(:link_count_per_topic).returns({topic1.id => 8, topic2.id => 3}) Topic.stubs(:select).returns(Topic); Topic.stubs(:where).returns(Topic) # bypass some activerecord methods Topic.stubs(:all).returns([topic1, topic2]) - top_referred_topics[:data][0].should == {topic_id: topic1.id, topic_title: topic1.title, topic_slug: topic1.slug, num_visits: 8 } - top_referred_topics[:data][1].should == {topic_id: topic2.id, topic_title: topic2.title, topic_slug: topic2.slug, num_visits: 3 } + top_referred_topics[:data][0].should == {topic_id: topic1.id, topic_title: topic1.title, topic_slug: topic1.slug, num_clicks: 8 } + top_referred_topics[:data][1].should == {topic_id: topic2.id, topic_title: topic2.title, topic_slug: topic2.slug, num_clicks: 3 } end end