docbrown/app/services
Daniel Uber e33b15e1e5
Add counts for number of views when showing referrers (#14600)
* 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.
2021-08-27 08:03:43 -05:00
..
articles Articles::DetectAnimatedImages: raise default timeout for FastImage (#14538) 2021-08-18 19:22:47 +02:00
audit Rubocop fixes (#11862) 2020-12-11 17:36:42 +03:00
authentication [15-Minute Fix] Ensure "Locked Screen" Checkbox Conditionally Renders (#14161) 2021-07-12 14:14:43 -06:00
badges Bump rubocop from 1.17.0 to 1.18.0 (#14107) 2021-07-01 13:51:49 +02:00
broadcasts/welcome_notification Bump rubocop-performance from 1.10.2 to 1.11.0 (#13471) 2021-04-22 09:31:25 -05:00
chat_channels Fix app/services' ruby 2.7 kwargs warnings (#13177) 2021-04-01 18:40:50 -04:00
color Remove redundant freeze calls (#14596) 2021-08-26 10:01:08 -04:00
credits Fix app/services' ruby 2.7 kwargs warnings (#13177) 2021-04-01 18:40:50 -04:00
edge_cache Bump rubocop-rails from 2.10.1 to 2.11.0 (#14043) 2021-06-22 11:25:28 -05:00
error_messages Remove redundant freeze calls (#14596) 2021-08-26 10:01:08 -04:00
exporter Fix app/services' ruby 2.7 kwargs warnings (#13177) 2021-04-01 18:40:50 -04:00
fastly_config Abstract DatadogStatsClient to ForemStatsClient (#12304) 2021-01-27 11:25:44 -05:00
feeds Use new UserSetting and UserNotificationSettings and Ignore Related User Table Fields (#14121) 2021-07-08 09:31:34 -05:00
follows Fix UI showing "Following" after unfollowing a user (#13757) 2021-05-19 17:40:38 +01:00
giphy
github Split Settings::Authentication from SiteConfig (#13095) 2021-04-12 09:41:09 +02:00
homepage [Search 2.0] Add query filters for profile, organization and tag index pages (#13510) 2021-04-27 08:49:47 +02:00
html Rename SiteConfig to Settings::General (#13573) 2021-05-21 14:45:37 +02:00
images [15 min fix] Fallback to the image URL if Cloudinary/Imgproxy are not configured (#13767) 2021-05-19 15:03:20 +02:00
loggers Abstract DatadogStatsClient to ForemStatsClient (#12304) 2021-01-27 11:25:44 -05:00
mailchimp Use new UserSetting and UserNotificationSettings and Ignore Related User Table Fields (#14121) 2021-07-08 09:31:34 -05:00
markdown_processor Remove redundant freeze calls (#14596) 2021-08-26 10:01:08 -04:00
mentions Expand @-mention functionality to posts (#13367) 2021-05-12 07:33:33 -07:00
moderator Use new UserSetting and UserNotificationSettings and Ignore Related User Table Fields (#14121) 2021-07-08 09:31:34 -05:00
notifications Bump rubocop from 1.18.4 to 1.19.0 (#14489) 2021-08-13 13:14:59 +07:00
organizations Organizations delete optimizations and refactoring (#13610) 2021-05-11 12:14:55 +03:00
payments Refactor credit purchasing (#13955) 2021-06-15 09:04:51 +07:00
podcasts handle openssl errors when checking podcast episode for https (#14439) 2021-08-09 12:52:20 -05:00
profile_fields Clean up forem:setup task (#13998) 2021-06-18 09:34:18 +07:00
push_notifications Have specs run without Redis and refactor ConsumerApp and Device (#13647) 2021-05-07 08:03:16 +02:00
re_captcha Rename SiteConfig to Settings::General (#13573) 2021-05-21 14:45:37 +02:00
search Bump rubocop from 1.18.1 to 1.18.3 (#14144) 2021-07-06 15:36:35 +02:00
secrets
settings Allow setting nil value in Settings::Upsert (#14228) 2021-07-20 10:57:09 -04:00
slack Rename SiteConfig to Settings::General (#13573) 2021-05-21 14:45:37 +02:00
tag_moderators Use new UserSetting and UserNotificationSettings and Ignore Related User Table Fields (#14121) 2021-07-08 09:31:34 -05:00
twitter_client Split Settings::Authentication from SiteConfig (#13095) 2021-04-12 09:41:09 +02:00
user_blocks Remove algolia from chat channel memberships (#6323) 2020-02-27 09:59:12 -05:00
user_subscriptions Bump rubocop from 1.17.0 to 1.18.0 (#14107) 2021-07-01 13:51:49 +02:00
users Profile generalization cleanup phase 2 (#14555) 2021-08-27 09:17:26 +07:00
webhook Fix app/services' ruby 2.7 kwargs warnings (#13177) 2021-04-01 18:40:50 -04:00
analytics_service.rb Add counts for number of views when showing referrers (#14600) 2021-08-27 08:03:43 -05:00
application_service.rb [deploy] Refactor 🚀 : Replaced Chat Channel Setting page with Preact component. (#8271) 2020-06-10 16:58:37 -04:00
article_api_index_service.rb Profile generalization cleanup phase 2 (#14555) 2021-08-27 09:17:26 +07:00
article_with_video_creation_service.rb Use new UserSetting and UserNotificationSettings and Ignore Related User Table Fields (#14121) 2021-07-08 09:31:34 -05:00
bulk_sql_delete.rb
email_digest.rb Use new UserSetting and UserNotificationSettings and Ignore Related User Table Fields (#14121) 2021-07-08 09:31:34 -05:00
email_digest_article_collector.rb Use new UserSetting and UserNotificationSettings and Ignore Related User Table Fields (#14121) 2021-07-08 09:31:34 -05:00
feature_flag.rb Adds a feature flag for Data Update Scripts (#12641) 2021-02-10 18:22:27 +02:00
flare_tag.rb [Search 2.0] Homepage query (#13339) 2021-04-21 12:41:24 +02:00
instrumentation.rb Instrument EmailDigestArticleCollector (#13153) 2021-03-29 09:33:32 -04:00
medium_article_retrieval_service.rb Fix app/services' ruby 2.7 kwargs warnings (#13177) 2021-04-01 18:40:50 -04:00
notifications.rb
rate_limit_checker.rb Pin posts to feed (#13807) 2021-06-04 10:54:53 +02:00
tag_adjustment_creation_service.rb [deploy] Rubocop: fix violations of Layout/LineLength (#9197) 2020-07-08 08:36:36 -05:00
tag_adjustment_update_service.rb