Skip to content

Commit

Permalink
Finalize some field tests (forem#21181)
Browse files Browse the repository at this point in the history
  • Loading branch information
benhalpern authored Jul 18, 2024
1 parent dfecd50 commit d64f629
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 33 deletions.
16 changes: 1 addition & 15 deletions app/controllers/sidebars_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,7 @@ def get_active_discussions
tag_names = current_user.cached_followed_tag_names
languages = current_user.languages.pluck(:language)
languages = [I18n.default_locale.to_s] if languages.empty?
order_variant = field_test(:active_discussion_ordering_07_03, participant: @user)
order = case order_variant
when "base"
Arel.sql("last_comment_at + (INTERVAL '1 minute' * LEAST(comment_score, 100)) DESC")
when "last_comment_plus_comment_score_capped_25"
Arel.sql("last_comment_at + (INTERVAL '1 minute' * LEAST(comment_score, 25)) DESC")
when "last_comment_plus_comment_score_capped_50"
Arel.sql("last_comment_at + (INTERVAL '1 minute' * LEAST(comment_score, 50)) DESC")
when "last_comment_plus_comment_score_capped_80"
Arel.sql("last_comment_at + (INTERVAL '1 minute' * LEAST(comment_score, 80)) DESC")
when "last_comment_plus_comment_score_capped_120"
Arel.sql("last_comment_at + (INTERVAL '1 minute' * LEAST(comment_score, 120)) DESC")
else
Arel.sql("last_comment_at + (INTERVAL '1 minute' * LEAST(comment_score, 100)) DESC")
end
order = Arel.sql("last_comment_at + (INTERVAL '1 minute' * LEAST(comment_score, 50)) DESC") # Determined via field test
@active_discussions = Article.published
.where("published_at > ?", 1.week.ago)
.where("comments_count > ?", 0)
Expand Down
6 changes: 2 additions & 4 deletions app/models/async_info.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,8 @@ def visible?(record:, query:)
end

def feed_style_preference_variable(user)
unwrapped_user = user.object # user here is actually a UserDecorator before. Need to unwrap.
after_date = unwrapped_user.registered_at >= Time.zone.parse("2024-02-20")
flag_on = FeatureFlag.enabled?(:feed_style_test_running)
return field_test(:feed_style_20240220, participant: unwrapped_user) if after_date && flag_on
# TODO: Let users set their own feed style preference
# Currently only at app level

feed_style_preference
end
Expand Down
16 changes: 2 additions & 14 deletions app/services/email_digest_article_collector.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,8 @@ def initialize(user)

def articles_to_send
# rubocop:disable Metrics/BlockLength
order_variant = field_test(:digest_article_ordering_06_25, participant: @user)
order = case order_variant
when "base"
Arel.sql("((score * ((feed_success_score * 12) + 0.1)) - (clickbait_score * 2)) DESC")
when "more_comment_score"
Arel.sql("((score * ((feed_success_score * 12) + 0.1)) - (clickbait_score * 2) + comment_score) DESC")
when "much_more_comment_score"
Arel.sql("((score * ((feed_success_score * 15) + 0.1)) - (clickbait_score * 2) + (comment_score * 5)) DESC") # rubocop:disable Layout/LineLength
when "much_much_more_comment_score"
Arel.sql("((score * ((feed_success_score * 20) + 0.1)) - (clickbait_score * 2) + (comment_score * 15)) DESC") # rubocop:disable Layout/LineLength
else
Arel.sql("((score * ((feed_success_score * 12) + 0.1)) - (clickbait_score * 2)) DESC")
end
instrument ARTICLES_TO_SEND, tags: { user_id: @user.id } do
order = Arel.sql("((score * ((feed_success_score * 12) + 0.1)) - (clickbait_score * 2)) DESC")
instrument ARTICLES_TO_SEND, tags: { user_id: @user.id } do
return [] unless should_receive_email?

articles = if @user.cached_followed_tag_names.any?
Expand Down
6 changes: 6 additions & 0 deletions config/field_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
experiments:
active_discussion_ordering_07_03:
started_at: 2024-07-03
ended_at: 2024-07-18
winner: last_comment_plus_comment_score_capped_50
variants:
- base
- last_comment_plus_comment_score_capped_25
Expand All @@ -51,6 +53,8 @@ experiments:

digest_article_ordering_06_25:
started_at: 2024-06-25
ended_at: 2024-07-18
winner: base
variants:
- base
- more_comment_score
Expand Down Expand Up @@ -364,6 +368,8 @@ experiments:
- user_views_pages_on_at_least_nine_different_days_within_two_weeks
feed_style_20240220:
started_at: 2024-02-20
ended_at: 2024-07-18
winner: basic
variants:
- basic
- rich
Expand Down

0 comments on commit d64f629

Please sign in to comment.