From cd18d2f436987f9c3008a3e7be2083cb8d370649 Mon Sep 17 00:00:00 2001 From: Ben Halpern Date: Tue, 26 May 2020 13:23:03 -0400 Subject: [PATCH] [deploy] Add alternate comment-oriented feed algos (#8042) --- app/controllers/stories/feeds_controller.rb | 2 ++ app/services/articles/feed.rb | 32 ++++++++++++++++++++- config/field_test.yml | 6 +++- spec/services/articles/feed_spec.rb | 2 ++ 4 files changed, 40 insertions(+), 2 deletions(-) diff --git a/app/controllers/stories/feeds_controller.rb b/app/controllers/stories/feeds_controller.rb index 0d0379a54..b88d67ae8 100644 --- a/app/controllers/stories/feeds_controller.rb +++ b/app/controllers/stories/feeds_controller.rb @@ -11,6 +11,8 @@ class Stories::FeedsController < ApplicationController "more_tag_weight_randomized_at_end_experiment" => :more_tag_weight_randomized_at_end_experiment, "more_experience_level_weight_randomized_at_end_experiment" => :more_experience_level_weight_randomized_at_end_experiment, "more_comments_randomized_at_end_experiment" => :more_comments_randomized_at_end_experiment, + "more_comments_medium_weight_randomized_at_end_experiment" => :more_comments_medium_weight_randomized_at_end_experiment, + "more_comments_minimal_weight_randomized_at_end_experiment" => :more_comments_minimal_weight_randomized_at_end_experiment, "mix_of_everything_experiment" => :mix_of_everything_experiment }.freeze diff --git a/app/services/articles/feed.rb b/app/services/articles/feed.rb index 6362abd81..610503073 100644 --- a/app/services/articles/feed.rb +++ b/app/services/articles/feed.rb @@ -93,6 +93,20 @@ module Articles stories end + # Test variation: the more comments a post has, the higher it's rated! + def more_comments_medium_weight_experiment + @comment_weight = 0.5 + _featured_story, stories = default_home_feed_and_featured_story(user_signed_in: true) + stories + end + + # Test variation: the more comments a post has, the higher it's rated! + def more_comments_minimal_weight_experiment + @comment_weight = 0.2 + _featured_story, stories = default_home_feed_and_featured_story(user_signed_in: true) + stories + end + def more_experience_level_weight_experiment @experience_level_weight = 3 _featured_story, stories = default_home_feed_and_featured_story(user_signed_in: true) @@ -100,7 +114,7 @@ module Articles end def mix_of_everything_experiment - case rand(10) + case rand(12) when 0 default_home_feed(user_signed_in: true) when 1 @@ -121,6 +135,10 @@ module Articles more_experience_level_weight_randomized_at_end_experiment when 9 more_comments_randomized_at_end_experiment + when 10 + more_comments_medium_weight_randomized_at_end_experiment + when 11 + more_comments_minimal_weight_randomized_at_end_experiment else default_home_feed(user_signed_in: true) end @@ -149,6 +167,18 @@ module Articles first_half(results).shuffle + last_half(results) end + def more_comments_medium_weight_randomized_at_end_experiment + @randomness = 0 + results = more_comments_medium_weight_experiment + first_half(results).shuffle + last_half(results) + end + + def more_comments_minimal_weight_randomized_at_end_experiment + @randomness = 0 + results = more_comments_minimal_weight_experiment + first_half(results).shuffle + last_half(results) + end + def rank_and_sort_articles(articles) ranked_articles = articles.each_with_object({}) do |article, result| article_points = score_single_article(article) diff --git a/config/field_test.yml b/config/field_test.yml index 3a6c3fd72..09757beae 100644 --- a/config/field_test.yml +++ b/config/field_test.yml @@ -12,6 +12,8 @@ experiments: - more_tag_weight_randomized_at_end_experiment - more_experience_level_weight_randomized_at_end_experiment - more_comments_randomized_at_end_experiment + - more_comments_medium_weight_randomized_at_end_experiment + - more_comments_minimal_weight_randomized_at_end_experiment weights: - 5 - 5 @@ -23,7 +25,9 @@ experiments: - 10 - 10 - 5 - - 35 + - 25 + - 5 + - 5 goals: - user_creates_comment - user_creates_reaction diff --git a/spec/services/articles/feed_spec.rb b/spec/services/articles/feed_spec.rb index 27e9effae..66a105f19 100644 --- a/spec/services/articles/feed_spec.rb +++ b/spec/services/articles/feed_spec.rb @@ -10,6 +10,8 @@ NON_DEFAULT_EXPERIMENTS = %i[ more_tag_weight_randomized_at_end_experiment more_experience_level_weight_randomized_at_end_experiment more_comments_randomized_at_end_experiment + more_comments_medium_weight_randomized_at_end_experiment + more_comments_minimal_weight_randomized_at_end_experiment mix_of_everything_experiment ].freeze