docbrown/spec/requests
Jeremy Friesen 816e92e549
Configurable weighted feed strategy (#15240)
* AB Test for Feed Strategy

Adding the plumbing for performing AB Tests on the feed strategy.

You can add the environment variable `AB_TEST_SERVICE_FEED_STRATEGY` to
specify the field test to run.

For example, from the forem application home directory you can run the
following to force a strategy for all users:

```console
AB_TEST_SERVICE_FEED_STRATEGY=original bin/start
```

Forcing the strategy can significantly help with quality assurance testing.

* Adding configurable weighted feed strategy

I wrote about this exploration on [DEV.to][1].  This particular
implementation provides significant configuration options for A/B
testing.

At it's core this `Articles::Feeds::WeightedQueryStrategy` provides a
means to query articles that are relevant to the user.  The
configuration helps us test and refine those values.

Further more this implementation introduces the idea of some common
interfaces for feed strategies.  I'm not happy with the naming
convention but we can work to change that.

This even hints at a mechanism for administrators to configure.

Related to forem/rfcs#314, as I work towards understanding the feed
algorithm. And #15180

[1]:https://dev.to/jeremyf/practicing-postgresql-and-postulating-improvements-5m

* Renaming AbTestService to AbExperiment

I'm loath to end any production class's filename with "test".  I don't
want minitest or rspec coming along and attempting to "test" that file.
In addition, I find that Experiment better describes the concept.

Also, per conversations with Michael K, we favor nouns objects to go
in app/models and verb objects to go in app/services.  That's a great
separation.

* Factoring AbExperiment into a Controller concern

I wish this could be a stand-alone module but the implementation of
field test has cases that require controller context.

* Sanitizing configurable weighted strategy cases

* Minor refactoring of coding structure

* Renaming parameter for clarity

* Renaming variable to avoid confusion

Prior to the commit, `env` is a controller variable.  The injected `env`
variable didn't collide, but did create just a bit of confusion.

With this change, I'm trying to disentangle from that variable.

* Factoring AbExperiment away from mixin concern

Per discussion with Michael K, we both agree that we do not like
controller concern mixins.  They can quickly complicate the legibility
of any given codebase.

This refactor provides a common and simplified interface for a Plain Old
Ruby Object (PORO) that accounts for the implementation considerations
of the underlying "field_test" controller method.

* Adding Datadog.tracer.trace around feed actions

* Adding featured_article_factor

Prior to this commit, there was no consideration for how moderators
engage with an article.  This is a first nudge towards that effort.

* Removing spec

Add a spec that says yes or no we're feature testing something seems
fragile.  Namely, why are we wanting to assert that as a truism.

* Helping ensure we're "tracing" the same things

From the code comment:

> Hey, why the to_a you say?  Because the
> LargeForemExperimental has already done this.  But the
> weighted strategy has not.  I also don't want to alter the
> weighted query implementation as it returns a lovely
> ActiveRecord::Relation.  So this is a concession.

* Addressing parameters for tracing function

* For weight feed query only count positive tags

A user assigns explicit points to the tags that they do or do not want
to see.  This change treats the negative explicit_points as an indicator
that they don't want to see the tag.

* Adding weighted factor for privileged user reactions

* Updating comments to better clarify

* Adding additional constraint for published_at

* Updating documentation and adding logger

* Adding documentation concerning method call

* Upping logging level for experiments

See conversations in https://github.com/forem/forem/pull/15240

* Adding group by clauses to appease postgres configs

* Injecting relevant scoring method's joins

Prior to this commit, we included all of the joins regardless of the
scoring methods chosen.  With this commit, we only inject joins that are
used with the commit.

What this would allow us to do is to then have some pre-cooked scoring
methods but not turn them on.  Or to turn off the more expensive scoring
methods.

* Adding feature flag for feed strategy experiment
2021-11-29 10:46:56 -05:00
..
admin Updating valid domain registration (#15436) 2021-11-19 10:05:00 -05:00
api/v0 ✂✂✂ Remove Connect (#14734) 2021-11-18 08:21:00 -06:00
articles Clean up feed-related code (#14707) 2021-09-17 09:23:32 +07:00
incoming_webhooks/mailchimp Use new UserSetting and UserNotificationSettings and Ignore Related User Table Fields (#14121) 2021-07-08 09:31:34 -05:00
notifications [deploy] Remove All Notification Count Helper Classes (#8221) 2020-06-02 09:48:02 -05:00
oauth Replace peform_enqueued_jobs with sidekiq_perform_enqueued_jobs in specs (#6454) 2020-03-04 11:39:48 -07:00
podcasts views/podcasts, views/podcast_episodes i18n (#15020) 2021-10-25 14:32:51 +01:00
shared_examples Hiding comments: an option to hide or keep children (#15178) 2021-11-18 11:57:40 +03:00
stories Configurable weighted feed strategy (#15240) 2021-11-29 10:46:56 -05:00
user ✂✂✂ Remove Connect (#14734) 2021-11-18 08:21:00 -06:00
api_secrets_create_spec.rb Rubocop: move dot in multi-line calls to leading position (#9262) 2020-07-16 15:51:11 +02:00
api_secrets_destroy_spec.rb Fix access token revoking (#3131) 2019-06-11 15:53:58 -04:00
article_approvals_spec.rb [deploy] Rubocop: fix violations of Layout/LineLength (#9197) 2020-07-08 08:36:36 -05:00
async_info_spec.rb Creator Onboarding: Creator Setup View (#14728) 2021-11-01 15:50:08 -04:00
badges_spec.rb Add badges index page. (#4236) 2019-10-06 17:34:52 -04:00
collections_spec.rb Show correct number in series truncation. (#13799) 2021-05-24 15:47:06 -06:00
comments_create_spec.rb When a user is blocked from commenting on an article, show correct error message (#15009) 2021-10-14 07:42:08 -06:00
comments_destroy_spec.rb Rubocop: Enable and fix Style/StringConcatenation (#9844) 2020-08-18 14:50:15 +02:00
comments_spec.rb Hiding comments: an option to hide or keep children (#15178) 2021-11-18 11:57:40 +03:00
comments_update_spec.rb [deploy] Remove redirect on comments#update (#10337) 2020-09-29 15:33:51 -04:00
credits_spec.rb [deploy] Rename classified listings (#7910) 2020-05-27 13:35:09 +00:00
dashboard_spec.rb views/dashboards i18n (#15069) 2021-11-29 07:19:16 -07:00
devices_spec.rb ForemMobile namespaced functions (#15212) 2021-11-23 15:25:29 -06:00
discussion_locks_spec.rb Update DiscussionLocksController (#14351) 2021-07-27 14:42:14 +02:00
display_ad_events_spec.rb [15-minute fix] Add ThrottledCall to DisplayAdEventsController (#12924) 2021-03-09 09:06:11 +07:00
editor_spec.rb RFC 50: Remove hardcoded paths and use path_helpers instead (in the specs) (#13549) 2021-04-28 21:32:51 +02:00
email_subscriptions_spec.rb Use new UserSetting and UserNotificationSettings and Ignore Related User Table Fields (#14121) 2021-07-08 09:31:34 -05:00
feedback_messages_spec.rb ✂✂✂ Remove Connect (#14734) 2021-11-18 08:21:00 -06:00
followings_spec.rb [deploy] Reintroduce sticky_nav changes (ab81f36 & 7f92855) (#10263) 2020-09-09 15:33:13 -04:00
follows_bulk_show_spec.rb [deploy] Bulk Fetch Follow Button Data for Users (#7676) 2020-05-08 13:58:58 -05:00
follows_bulk_update_spec.rb Update all followed tag with one click (#11454) 2021-01-05 16:15:37 +01:00
follows_create_spec.rb Clear the cached settings before testing the rate limiter (#13669) 2021-05-05 14:34:22 -05:00
follows_show_spec.rb Rubocop: enable and fix Style/Send and Style/Next (#9366) 2020-07-20 16:28:00 +02:00
ga_events_spec.rb Rename SiteConfig to Settings::General (#13573) 2021-05-21 14:45:37 +02:00
github_repos_spec.rb ✂✂✂ Remove Connect (#14734) 2021-11-18 08:21:00 -06:00
html_variant_successes_spec.rb Replace peform_enqueued_jobs with sidekiq_perform_enqueued_jobs in specs (#6454) 2020-03-04 11:39:48 -07:00
html_variant_trials_spec.rb Replace peform_enqueued_jobs with sidekiq_perform_enqueued_jobs in specs (#6454) 2020-03-04 11:39:48 -07:00
image_uploads_spec.rb Refactor:Change Image Article Upload Path to uploads/articles (#12668) 2021-02-15 11:52:00 -06:00
invitations_spec.rb Rename SiteConfig to Settings::General (#13573) 2021-05-21 14:45:37 +02:00
liquid_embeds_spec.rb [deploy] Decouple Twitter authentication from fetching tweets (#7920) 2020-05-19 18:05:41 -04:00
liquid_tags_request_spec.rb [deploy] Add LiquidTagsController (#10241) 2020-09-08 12:07:33 -04:00
listings_spec.rb ✂✂✂ Remove Connect (#14734) 2021-11-18 08:21:00 -06:00
moderations_spec.rb Rename User.dev_account to User.staff_account (#14321) 2021-07-26 10:46:26 -04:00
notification_counts_spec.rb [deploy] Optimization:Use Scope and current_user to Get Notification Count (#8177) 2020-06-01 09:27:46 -05:00
notification_subscriptions_spec.rb [deploy] Rubocop: fix violations of Layout/LineLength (#9197) 2020-07-08 08:36:36 -05:00
notifications_spec.rb Rename User.dev_account to User.staff_account (#14321) 2021-07-26 10:46:26 -04:00
onboardings_spec.rb Rename SiteConfig to Settings::General (#13573) 2021-05-21 14:45:37 +02:00
open_search_spec.rb Clean up SiteConfig (#13738) 2021-05-18 09:38:31 +07:00
organizations_update_spec.rb Upgrade Rails to 6.1.3.1 (#11333) 2021-04-05 10:39:48 -04:00
page_views_spec.rb Extract page view updates into workers (#12686) 2021-02-17 09:24:05 +07:00
pages_spec.rb I18n copy on Tags index page (#14891) 2021-10-08 10:21:06 +07:00
poll_skips_spec.rb Small ActiveRecord optimizations: begone race conditions and hello bulk insert (#8436) 2020-06-15 17:57:14 +02:00
poll_votes_spec.rb Fix rubocop detected offenses (#4552) 2019-10-24 11:53:03 -04:00
profile_field_groups_request_spec.rb Deployment Task: Update onboarding fields prior to #11629 (#11704) 2020-12-07 14:57:18 -05:00
profile_pins_spec.rb [deploy] Finalize deleting user associations (#5624) 2020-01-23 11:29:47 -05:00
profile_preview_cards_spec.rb Profile generalization cleanup phase 2 (#14555) 2021-08-27 09:17:26 +07:00
profiles_request_spec.rb Drop profile columns from user (#10707) 2020-12-03 08:14:38 +07:00
rating_votes_spec.rb Add experience level averaging to articles (#1922) 2019-02-28 08:17:29 -08:00
reactions_spec.rb Don't try to create invalid RatingVote (#14706) 2021-09-14 09:41:59 +07:00
reading_list_items_spec.rb [deploy] Fix Reading List Counter Without last_reacted_at Default (#10933) 2020-10-19 13:26:19 -05:00
registrations_spec.rb Fix profile image bug on email registration (#14991) 2021-10-08 14:30:57 -04:00
response_templates_spec.rb [deploy] Rubocop: fix violations of Layout/LineLength (#9197) 2020-07-08 08:36:36 -05:00
search_spec.rb ✂✂✂ Remove Connect (#14734) 2021-11-18 08:21:00 -06:00
sidebars_spec.rb Rename SiteConfig to Settings::General (#13573) 2021-05-21 14:45:37 +02:00
sitemaps_spec.rb Fix legacy sitemap logic (#14926) 2021-10-07 08:59:16 -04:00
social_previews_spec.rb Remove SheCoded Specific Code (#13363) 2021-04-12 11:04:58 -07:00
stories_index_spec.rb Rubocop fixes (#14868) 2021-09-30 13:22:09 -04:00
stories_show_spec.rb Article layout (#14753) 2021-09-30 19:08:06 +02:00
stripe_active_cards_spec.rb Abstract DatadogStatsClient to ForemStatsClient (#12304) 2021-01-27 11:25:44 -05:00
tag_adjustments_spec.rb [deploy] Rubocop: fix violations of Layout/LineLength (#9197) 2020-07-08 08:36:36 -05:00
tags_spec.rb Update TagsController#index query (#15202) 2021-10-27 08:17:53 -04:00
universal_links_spec.rb Add exclusion to AASA supported paths (#14593) 2021-08-26 10:17:39 -06:00
user_blocks_spec.rb ✂✂✂ Remove Connect (#14734) 2021-11-18 08:21:00 -06:00
user_subscriptions_spec.rb Improve error message of User Subscriptions (#11689) 2020-12-01 08:41:49 -08:00
users_onboarding_spec.rb Profile generalization cleanup phase 2 (#14555) 2021-08-27 09:17:26 +07:00
video_states_update_spec.rb Rename SiteConfig to Settings::General (#13573) 2021-05-21 14:45:37 +02:00
videos_spec.rb Videos UI update (#15177) 2021-10-28 09:34:44 +02:00