Change the title Visits to Clicks in referral tables on admin dashboard

This commit is contained in:
Neil Lalonde 2013-05-06 11:56:35 -04:00
parent b944157d88
commit 69be7d0ad1
4 changed files with 34 additions and 34 deletions

View File

@ -176,7 +176,7 @@
<thead> <thead>
<tr> <tr>
<th class="title">{{top_referred_topics.title}} ({{i18n admin.dashboard.reports.last_30_days}})</th> <th class="title">{{top_referred_topics.title}} ({{i18n admin.dashboard.reports.last_30_days}})</th>
<th>{{top_referred_topics.ytitles.num_visits}}</th> <th>{{top_referred_topics.ytitles.num_clicks}}</th>
</tr> </tr>
</thead> </thead>
{{#unless loading}} {{#unless loading}}
@ -184,7 +184,7 @@
<tbody> <tbody>
<tr> <tr>
<td class="title"><a href="/t/{{unbound data.topic_slug}}/{{unbound data.topic_id}}">{{shorten data.topic_title}}</a></td> <td class="title"><a href="/t/{{unbound data.topic_slug}}/{{unbound data.topic_id}}">{{shorten data.topic_title}}</a></td>
<td class="value">{{data.num_visits}}</td> <td class="value">{{data.num_clicks}}</td>
</tr> </tr>
</tbody> </tbody>
{{/each}} {{/each}}
@ -197,7 +197,7 @@
<thead> <thead>
<tr> <tr>
<th class="title">{{top_traffic_sources.title}} ({{i18n admin.dashboard.reports.last_30_days}})</th> <th class="title">{{top_traffic_sources.title}} ({{i18n admin.dashboard.reports.last_30_days}})</th>
<th>{{top_traffic_sources.ytitles.num_visits}}</th> <th>{{top_traffic_sources.ytitles.num_clicks}}</th>
<th>{{top_traffic_sources.ytitles.num_topics}}</th> <th>{{top_traffic_sources.ytitles.num_topics}}</th>
<th>{{top_traffic_sources.ytitles.num_users}}</th> <th>{{top_traffic_sources.ytitles.num_users}}</th>
</tr> </tr>
@ -207,7 +207,7 @@
<tbody> <tbody>
<tr> <tr>
<td class="title">{{domain}}</td> <td class="title">{{domain}}</td>
<td class="value">{{num_visits}}</td> <td class="value">{{num_clicks}}</td>
<td class="value">{{num_topics}}</td> <td class="value">{{num_topics}}</td>
<td class="value">{{num_users}}</td> <td class="value">{{num_users}}</td>
</tr> </tr>
@ -222,7 +222,7 @@
<thead> <thead>
<tr> <tr>
<th class="title">{{top_referrers.title}} ({{i18n admin.dashboard.reports.last_30_days}})</th> <th class="title">{{top_referrers.title}} ({{i18n admin.dashboard.reports.last_30_days}})</th>
<th>{{top_referrers.ytitles.num_visits}}</th> <th>{{top_referrers.ytitles.num_clicks}}</th>
<th>{{top_referrers.ytitles.num_topics}}</th> <th>{{top_referrers.ytitles.num_topics}}</th>
</tr> </tr>
</thead> </thead>
@ -231,7 +231,7 @@
<tbody> <tbody>
<tr> <tr>
<td class="title">{{#linkTo adminUser username}}{{username}}{{/linkTo}}</td> <td class="title">{{#linkTo adminUser username}}{{username}}{{/linkTo}}</td>
<td class="value">{{num_visits}}</td> <td class="value">{{num_clicks}}</td>
<td class="value">{{num_topics}}</td> <td class="value">{{num_topics}}</td>
</tr> </tr>
</tbody> </tbody>

View File

@ -30,16 +30,16 @@ class IncomingLinksReport
# Return top 10 users who brought traffic to the site within the last 30 days # Return top 10 users who brought traffic to the site within the last 30 days
def self.report_top_referrers(report) 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") 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 num_topics = topic_count_per_user
report.data = [] report.data = []
num_visits.keys.each do |username| num_clicks.keys.each do |username|
report.data << {username: username, num_visits: num_visits[username], num_topics: num_topics[username]} report.data << {username: username, num_clicks: num_clicks[username], num_topics: num_topics[username]}
end 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 end
def self.per_user 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 # Return top 10 domains that brought traffic to the site within the last 30 days
def self.report_top_traffic_sources(report) 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_topics] = I18n.t("reports.#{report.type}.num_topics")
report.y_titles[:num_users] = I18n.t("reports.#{report.type}.num_users") 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_topics = topic_count_per_domain
num_users = user_count_per_domain num_users = user_count_per_domain
report.data = [] report.data = []
num_visits.keys.each do |domain| num_clicks.keys.each do |domain|
report.data << {domain: domain, num_visits: num_visits[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], num_users: num_users[domain]}
end 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 end
def self.per_domain def self.per_domain
@ -89,15 +89,15 @@ class IncomingLinksReport
def self.report_top_referred_topics(report) def self.report_top_referred_topics(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")
num_visits = link_count_per_topic num_clicks = link_count_per_topic
num_visits = num_visits.to_a.sort_by {|x| x[1]}.last(10).reverse # take the top 10 num_clicks = num_clicks.to_a.sort_by {|x| x[1]}.last(10).reverse # take the top 10
report.data = [] report.data = []
topics = Topic.select('id, slug, title').where('id in (?)', num_visits.map {|z| z[0]}).all topics = Topic.select('id, slug, title').where('id in (?)', num_clicks.map {|z| z[0]}).all
num_visits.each do |topic_id, num_visits| num_clicks.each do |topic_id, num_clicks|
topic = topics.find {|t| t.id == topic_id} topic = topics.find {|t| t.id == topic_id}
if topic 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
end end
report.data report.data

View File

@ -337,18 +337,18 @@ en:
top_referrers: top_referrers:
title: "Top Referrers" title: "Top Referrers"
xaxis: "User" xaxis: "User"
num_visits: "Visits" num_clicks: "Clicks"
num_topics: "Topics" num_topics: "Topics"
top_traffic_sources: top_traffic_sources:
title: "Top Traffic Sources" title: "Top Traffic Sources"
xaxis: "Domain" xaxis: "Domain"
num_visits: "Visits" num_clicks: "Clicks"
num_topics: "Topics" num_topics: "Topics"
num_users: "Users" num_users: "Users"
top_referred_topics: top_referred_topics:
title: "Top Referred Topics" title: "Top Referred Topics"
xaxis: "Topic" xaxis: "Topic"
num_visits: "Visits" num_clicks: "Clicks"
dashboard: dashboard:
rails_env_warning: "Your server is running in %{env} mode." rails_env_warning: "Your server is running in %{env} mode."

View File

@ -15,7 +15,7 @@ describe IncomingLinksReport do
top_referrers[:title].should be_present top_referrers[:title].should be_present
top_referrers[:xaxis].should be_present top_referrers[:xaxis].should be_present
top_referrers[:ytitles].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 top_referrers[:ytitles][:num_topics].should be_present
end end
@ -27,8 +27,8 @@ describe IncomingLinksReport do
it 'with some IncomingLink records, it returns correct data' do it 'with some IncomingLink records, it returns correct data' do
IncomingLinksReport.stubs(:link_count_per_user).returns({'luke' => 4, 'chewie' => 2}) IncomingLinksReport.stubs(:link_count_per_user).returns({'luke' => 4, 'chewie' => 2})
IncomingLinksReport.stubs(:topic_count_per_user).returns({'luke' => 2, 'chewie' => 1}) 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][0].should == {username: 'luke', num_clicks: 4, num_topics: 2}
top_referrers[:data][1].should == {username: 'chewie', num_visits: 2, num_topics: 1} top_referrers[:data][1].should == {username: 'chewie', num_clicks: 2, num_topics: 1}
end end
end end
@ -46,7 +46,7 @@ describe IncomingLinksReport do
top_traffic_sources[:title].should be_present top_traffic_sources[:title].should be_present
top_traffic_sources[:xaxis].should be_present top_traffic_sources[:xaxis].should be_present
top_traffic_sources[:ytitles].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_topics].should be_present
top_traffic_sources[:ytitles][:num_users].should be_present top_traffic_sources[:ytitles][:num_users].should be_present
end end
@ -60,8 +60,8 @@ describe IncomingLinksReport do
IncomingLinksReport.stubs(:link_count_per_domain).returns({'twitter.com' => 8, 'facebook.com' => 3}) 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(:topic_count_per_domain).returns({'twitter.com' => 2, 'facebook.com' => 3})
IncomingLinksReport.stubs(:user_count_per_domain).returns({'twitter.com' => 4, 'facebook.com' => 1}) 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][0].should == {domain: 'twitter.com', num_clicks: 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][1].should == {domain: 'facebook.com', num_clicks: 3, num_topics: 3, num_users: 1}
end end
end end
@ -77,7 +77,7 @@ describe IncomingLinksReport do
top_referred_topics[:title].should be_present top_referred_topics[:title].should be_present
top_referred_topics[:xaxis].should be_present top_referred_topics[:xaxis].should be_present
top_referred_topics[:ytitles].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 end
it 'with no IncomingLink records, it returns correct data' do 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}) 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(:select).returns(Topic); Topic.stubs(:where).returns(Topic) # bypass some activerecord methods
Topic.stubs(:all).returns([topic1, topic2]) 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][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_visits: 3 } top_referred_topics[:data][1].should == {topic_id: topic2.id, topic_title: topic2.title, topic_slug: topic2.slug, num_clicks: 3 }
end end
end end