* Add counts for number of views when showing referrers
We're sampling unauthenticated page views (every 10th visit is
recorded) and using the "counts_for_number_of_views" attribute to mark
the 10x weight of these sampled events.
The referrers section of the statistics page however was counting the
number of page view rows (without regard to the weight) and it looked
like external referrers (like a google search) were counting 10 times
on the statistics page.
Update the analytics service to show the sum of the weights, rather
than the count of events, on the "Traffic Source Summary" of the
article stats page.
This is loaded from /api/analytics/referrers?article_id=:id on the
front end.
Needs a test that demonstrates this (currently all specs for this
stayed green suggesting the coverage didn't include anything that
represents this situation).
* Avoid calling sum twice by reusing the value alias
the .sum(:column) method in this chain creates an alias 'select
sum(column) as sum_column' which can be used here to avoid
recalculating the sum once for sorting and again for return value.
Sort by the return value's alias.
* Update the test to include weighted page views
Since we want to demonstrate that the count shown for visits matches
the sum of the weighted page views, add weighting to the top url
visits and expect the sum of the weights to be presented.