docbrown/app/controllers
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 Provide COC and TOS Checkboxes During Creator Onboarding (#15430) 2021-11-22 07:41:05 -07:00
api/v0 Auto register Forems on Discover (#14962) 2021-10-06 10:51:15 -04:00
concerns ✂✂✂ Remove Connect (#14734) 2021-11-18 08:21:00 -06:00
incoming_webhooks Use new UserSetting and UserNotificationSettings and Ignore Related User Table Fields (#14121) 2021-07-08 09:31:34 -05:00
notifications
oauth
stories Configurable weighted feed strategy (#15240) 2021-11-29 10:46:56 -05:00
users ✂✂✂ Remove Connect (#14734) 2021-11-18 08:21:00 -06:00
api_secrets_controller.rb Removing Settings::General.email_addresses (#13958) 2021-06-11 12:34:34 +03:00
application_controller.rb Try env var from request for Nginx ip address (#15201) 2021-10-27 16:00:20 -04:00
application_metal_controller.rb
article_approvals_controller.rb
articles_controller.rb Clean up feed-related code (#14707) 2021-09-17 09:23:32 +07:00
async_info_controller.rb Creator Onboarding: Creator Setup View (#14728) 2021-11-01 15:50:08 -04:00
badges_controller.rb
collections_controller.rb Fix Bug: Series index page showing series with 0 articles -#9658 (#11227) 2020-11-03 09:10:46 +01:00
comments_controller.rb Hiding comments: an option to hide or keep children (#15178) 2021-11-18 11:57:40 +03:00
confirmations_controller.rb Redirect to creator settings page where necessary (#15298) 2021-11-11 14:44:49 +02:00
credits_controller.rb Refactor credit purchasing (#13955) 2021-06-15 09:04:51 +07:00
dashboards_controller.rb In dashboard show api eager load collection with articles (#14677) 2021-09-09 11:11:03 +01:00
deep_links_controller.rb Add exclusion to AASA supported paths (#14593) 2021-08-26 10:17:39 -06:00
devices_controller.rb ForemMobile namespaced functions (#15212) 2021-11-23 15:25:29 -06:00
discussion_locks_controller.rb Update DiscussionLocksController (#14351) 2021-07-27 14:42:14 +02:00
display_ad_events_controller.rb [15-minute fix] Add ThrottledCall to DisplayAdEventsController (#12924) 2021-03-09 09:06:11 +07:00
email_authorizations_controller.rb
email_subscriptions_controller.rb ✂✂✂ Remove Connect (#14734) 2021-11-18 08:21:00 -06:00
feedback_messages_controller.rb Use constants for Permitted params in controller (#14895) 2021-10-05 09:00:14 -04:00
followings_controller.rb
follows_controller.rb Bug Fix: Following an organization from article's sidebar creates an incorrect follow record (#15093) 2021-11-05 12:40:20 -04:00
ga_events_controller.rb Rename SiteConfig to Settings::General (#13573) 2021-05-21 14:45:37 +02:00
github_repos_controller.rb Fix Ruby 2.7 kwargs' warnings & misc spec warnings (#13256) 2021-04-06 16:57:59 -04:00
html_variant_successes_controller.rb
html_variant_trials_controller.rb
image_uploads_controller.rb
invitations_controller.rb
liquid_embeds_controller.rb
liquid_tags_controller.rb Remove redundant freeze calls (#14596) 2021-08-26 10:01:08 -04:00
listings_controller.rb ✂✂✂ Remove Connect (#14734) 2021-11-18 08:21:00 -06:00
moderations_controller.rb ✂✂✂ Remove Connect (#14734) 2021-11-18 08:21:00 -06:00
notification_subscriptions_controller.rb Rename unidiomatic methods (#13328) 2021-04-09 10:59:56 -05:00
notifications_controller.rb
omniauth_callbacks_controller.rb Guarding against spam from OAuth Sources (#15404) 2021-11-18 16:26:39 -05:00
onboardings_controller.rb
open_search_controller.rb
organizations_controller.rb Use constants for Permitted params in controller (#14895) 2021-10-05 09:00:14 -04:00
page_views_controller.rb Extract page view updates into workers (#12686) 2021-02-17 09:24:05 +07:00
pages_controller.rb RFC #74, Pt. 2: Private Forem Landing Page (#13819) 2021-06-10 11:46:24 -06:00
passwords_controller.rb Add a notification on password reset (#14968) 2021-10-07 14:48:01 -04:00
podcast_episodes_controller.rb Fix and clean up podcast pages (#15004) 2021-10-15 17:38:57 -04:00
podcasts_controller.rb Use constants for Permitted params in controller (#14895) 2021-10-05 09:00:14 -04:00
poll_skips_controller.rb Use constants for Permitted params in controller (#14895) 2021-10-05 09:00:14 -04:00
poll_votes_controller.rb Use constants for Permitted params in controller (#14895) 2021-10-05 09:00:14 -04:00
pro_accounts_controller.rb
profile_field_groups_controller.rb
profile_pins_controller.rb Create DiscussionLocks (#13905) 2021-06-10 11:04:33 -04:00
profile_preview_cards_controller.rb Add JSON representation of Profile Preview Card info (#14296) 2021-07-21 16:23:54 +01:00
profiles_controller.rb Profile generalization: cleanup (#12947) 2021-08-20 16:36:02 +02:00
rating_votes_controller.rb
reactions_controller.rb Don't try to create invalid RatingVote (#14706) 2021-09-14 09:41:59 +07:00
reading_list_items_controller.rb
registrations_controller.rb Adding ability to block domains from registration (#15397) 2021-11-16 18:56:01 -05:00
response_templates_controller.rb
search_controller.rb ✂✂✂ Remove Connect (#14734) 2021-11-18 08:21:00 -06:00
service_worker_controller.rb Revert "Revert "Removed service worker (#12974)" (#13014)" (#13015) 2021-03-17 10:57:56 -04:00
sidebars_controller.rb Split Settings::Campaign from SiteConfig (#13238) 2021-04-19 10:01:03 +07:00
sitemaps_controller.rb I18n copy on Tags index page (#14891) 2021-10-08 10:21:06 +07:00
social_previews_controller.rb
stories_controller.rb Configurable weighted feed strategy (#15240) 2021-11-29 10:46:56 -05:00
stripe_active_cards_controller.rb Use constants for Permitted params in controller (#14895) 2021-10-05 09:00:14 -04:00
tag_adjustments_controller.rb Fix new Rubocop violations (#10808) 2020-10-20 09:28:53 -04:00
tags_controller.rb Update TagsController#index query (#15202) 2021-10-27 08:17:53 -04:00
user_blocks_controller.rb ✂✂✂ Remove Connect (#14734) 2021-11-18 08:21:00 -06:00
user_subscriptions_controller.rb
users_controller.rb Tokenize settings menu and add French translations (#14905) 2021-10-06 17:53:58 +02:00
video_states_controller.rb Rename SiteConfig to Settings::General (#13573) 2021-05-21 14:45:37 +02:00
videos_controller.rb