Remove users column from Top Traffic Sources table on dashboard. It's not useful and very expensive to calculate.
This commit is contained in:
parent
f337aea982
commit
1552c4b69e
|
@ -236,7 +236,6 @@
|
|||
<th class="title">{{top_traffic_sources.title}} ({{i18n admin.dashboard.reports.last_30_days}})</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>
|
||||
</thead>
|
||||
{{#unless loading}}
|
||||
|
@ -246,7 +245,6 @@
|
|||
<td class="title">{{domain}}</td>
|
||||
<td class="value">{{num_clicks}}</td>
|
||||
<td class="value">{{num_topics}}</td>
|
||||
<td class="value">{{num_users}}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
{{/each}}
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue