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>
<tr>
<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>
</thead>
{{#unless loading}}
@ -184,7 +184,7 @@
<tbody>
<tr>
<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>
</tbody>
{{/each}}
@ -197,7 +197,7 @@
<thead>
<tr>
<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_users}}</th>
</tr>
@ -207,7 +207,7 @@
<tbody>
<tr>
<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_users}}</td>
</tr>
@ -222,7 +222,7 @@
<thead>
<tr>
<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>
</tr>
</thead>
@ -231,7 +231,7 @@
<tbody>
<tr>
<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>
</tr>
</tbody>

View File

@ -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

View File

@ -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."

View File

@ -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