New Digest field test (#20939)

This commit is contained in:
Ben Halpern 2024-05-10 18:05:44 -04:00 committed by GitHub
parent 021213b841
commit f8df0e550c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 47 additions and 59 deletions

View file

@ -7,7 +7,6 @@ class DigestMailer < ApplicationMailer
@billboards = params[:billboards]
@unsubscribe = generate_unsubscribe_token(@user.id, :email_digest_periodic)
@article_design_variant = field_test(:digest_articles_design_05_02, participant: @user)
subject = generate_title
# set sendgrid category in the header using smtp api

View file

@ -12,7 +12,25 @@ class EmailDigestArticleCollector
def articles_to_send
# rubocop:disable Metrics/BlockLength
order = Arel.sql("((score * (feed_success_score + 0.1)) - clickbait_score) DESC")
order_variant = field_test(:digest_article_ordering_05_09, participant: @user)
order = case order_variant
when "base"
Arel.sql("((score * (feed_success_score + 0.1)) - clickbait_score) DESC")
when "more_weight_on_feed_success"
Arel.sql("((score * (feed_success_score + 0.2)) - clickbait_score) DESC")
when "much_more_weight_on_feed_success"
Arel.sql("((score * (feed_success_score + 0.3)) - clickbait_score) DESC")
when "more_weight_on_clickbait"
Arel.sql("((score * (feed_success_score + 0.1)) - (clickbait_score * 0.5)) DESC")
when "much_more_weight_on_clickbait"
Arel.sql("((score * (feed_success_score + 0.1)) - (clickbait_score * 0.8)) DESC")
when "more_weight_on_comments"
Arel.sql("((score * (feed_success_score + 0.1)) - clickbait_score + comment_score) DESC")
when "much_more_weight_on_comments"
Arel.sql("((score * (feed_success_score + 0.1)) - clickbait_score + (comment_score * 2)) DESC")
else
Arel.sql("((score * (feed_success_score + 0.1)) - clickbait_score) DESC")
end
instrument ARTICLES_TO_SEND, tags: { user_id: @user.id } do
return [] unless should_receive_email?

View file

@ -34,67 +34,13 @@
<!-- Articles List -->
<% @articles.each_with_index do |article, i| %>
<tr>
<td bgcolor="#FFFFFF" style="padding: <%= i.zero? ? "27" : "17" %>px 2px 0px; text-align: left;">
<% case @article_design_variant %>
<% when "base" %>
<td bgcolor="#FFFFFF" style="padding: <%= i.zero? ? "27" : "17" %>px 0px 0px; text-align: left;">
<div style="border:2px solid #0a0a0a;border-radius:12px;padding:12px 12px 3px;">
<a href="<%= article_url(article) %>?context=digest" style="font-weight: bold; color:#0a0a0a; font-size: 16px;display:block;"><%= article.title.strip %></a>
<p style="margin-top: 5px; font-size: 14px; color: #808080;">
<%= truncate(article.description, length: 180) %>
</p>
<% when "base_with_user" %>
<a href="<%= article_url(article) %>?context=digest" style="font-weight: bold; color:#0a0a0a; font-size: 16px;display:block;"><%= article.title.strip %></a>
<% if article.cached_user.present? %>
<p style="margin-top: 8px;margin-bottom: 3px; font-size: 14px; color: #6b6b6b;font-weight:700;margin-left:-2px;">
<img alt="<%= article.cached_user.name %> logo" src="<%= article.cached_user.profile_image_90 %>" style="height:18px;width:18px;border-radius:100px;vertical-align:-4px;border:1px solid #808080;" loading="lazy" />
<%= article.cached_user.name %>
</p>
<% end %>
<p style="margin-top: 5px; font-size: 14px; color: #808080;">
<%= truncate(article.description, length: 180) %>
</p>
<% when "base_with_tags" %>
<a href="<%= article_url(article) %>?context=digest" style="font-weight: bold; color:#0a0a0a; font-size: 16px;display:block;"><%= article.title.strip %></a>
<p style="margin-top: 6px;margin-bottom: 6px; font-size: 13px; color: #6b6b6b;">
<% article.decorate.cached_tag_list_array.each do |tag| %>
<span style="display:inline-block;background:#e6e6e6;border: 1px solid #dedede;border-radius:3px;padding:1px 4px;margin-right:3px;">#<%= tag %></span>
<% end %>
</p>
<p style="margin-top: 5px; font-size: 14px; color: #808080;">
<%= truncate(article.description, length: 180) %>
</p>
<% when "border" %>
<div style="border:2px solid #0a0a0a;border-radius:12px;padding:12px 12px 3px;">
<a href="<%= article_url(article) %>?context=digest" style="font-weight: bold; color:#0a0a0a; font-size: 16px;display:block;"><%= article.title.strip %></a>
<p style="margin-top: 5px; font-size: 14px; color: #808080;">
<%= truncate(article.description, length: 180) %>
</p>
</div>
<% when "border_with_user" %>
<div style="border:2px solid #0a0a0a;border-radius:12px;padding:12px 12px 3px;">
<a href="<%= article_url(article) %>?context=digest" style="font-weight: bold; color:#0a0a0a; font-size: 16px;display:block;"><%= article.title.strip %></a>
<% if article.cached_user.present? %>
<p style="margin-top: 8px;margin-bottom: 3px; font-size: 14px; color: #6b6b6b;font-weight:700;margin-left:-2px;">
<img alt="<%= article.cached_user.name %> logo" src="<%= article.cached_user.profile_image_90 %>" style="height:18px;width:18px;border-radius:100px;vertical-align:-4px;border:1px solid #808080;" loading="lazy" />
<%= article.cached_user.name %>
</p>
<% end %>
<p style="margin-top: 5px; font-size: 14px; color: #808080;">
<%= truncate(article.description, length: 180) %>
</p>
</div>
<% when "border_with_tags" %>
<div style="border:2px solid #0a0a0a;border-radius:12px;padding:12px 12px 3px;">
<a href="<%= article_url(article) %>?context=digest" style="font-weight: bold; color:#0a0a0a; font-size: 16px;display:block;"><%= article.title.strip %></a>
<p style="margin-top: 6px;margin-bottom: 6px; font-size: 13px; color: #6b6b6b;">
<% article.decorate.cached_tag_list_array.each do |tag| %>
<span style="display:inline-block;background:#e6e6e6;border: 1px solid #dedede;border-radius:3px;padding:1px 4px;margin-right:3px;">#<%= tag %></span>
<% end %>
</p>
<p style="margin-top: 5px; font-size: 14px; color: #808080;">
<%= truncate(article.description, length: 180) %>
</p>
</div>
<% end %>
</div>
</td>
</tr>
<% end %>

View file

@ -27,8 +27,33 @@
################################################################################
################################################################################
experiments:
digest_article_ordering_05_09:
started_at: 2024-05-09
variants:
- base
- more_weight_on_feed_success
- much_more_weight_on_feed_success
- more_weight_on_clickbait
- much_more_weight_on_clickbait
- more_weight_on_comments
- much_more_weight_on_comments
weights:
- 40
- 10
- 10
- 10
- 10
- 10
- 10
goals:
- user_creates_pageview
- user_creates_article_reaction
- user_views_pages_on_at_least_two_different_days_within_a_week
- user_views_pages_on_at_least_four_different_days_within_a_week
digest_articles_design_05_02:
started_at: 2024-05-02
ended_at: 2024-05-09
winner: border
variants:
- base
- base_with_user