diff --git a/app/controllers/stories_controller.rb b/app/controllers/stories_controller.rb index 211afc401..92306c899 100644 --- a/app/controllers/stories_controller.rb +++ b/app/controllers/stories_controller.rb @@ -260,7 +260,6 @@ class StoriesController < ApplicationController not_found unless @article.user @article_show = true - @variant_number = params[:variant_version] || (user_signed_in? ? 0 : rand(2)) @user = @article.user @organization = @article.organization diff --git a/app/models/html_variant.rb b/app/models/html_variant.rb index 6fbffb183..6a26bc0be 100644 --- a/app/models/html_variant.rb +++ b/app/models/html_variant.rb @@ -1,7 +1,7 @@ class HtmlVariant < ApplicationRecord include CloudinaryHelper - GROUP_NAMES = %w[article_show_sidebar_cta article_show_below_article_cta badge_landing_page campaign].freeze + GROUP_NAMES = %w[article_show_below_article_cta badge_landing_page campaign].freeze validates :html, presence: true validates :name, uniqueness: true @@ -23,11 +23,11 @@ class HtmlVariant < ApplicationRecord end class << self - def find_for_test(tags = [], group = "article_show_sidebar_cta") + def find_for_test(tags = [], group = "article_show_below_article_cta") tags_array = tags + ["", nil] if rand(10) == 1 # 10% return completely random find_random_for_test(tags_array, group) - else # 90% chance return one in top 10 + else # 90% chance return one of the top posts find_top_for_test(tags_array, group) end end @@ -36,7 +36,7 @@ class HtmlVariant < ApplicationRecord def find_top_for_test(tags_array, group) where(group: group, approved: true, published: true, target_tag: tags_array). - order("success_rate DESC").limit(rand(1..15)).sample + order("success_rate DESC").limit(rand(1..20)).sample end def find_random_for_test(tags_array, group) diff --git a/app/views/articles/_actions.html.erb b/app/views/articles/_actions.html.erb index 78ccafcac..1d8a42c6b 100644 --- a/app/views/articles/_actions.html.erb +++ b/app/views/articles/_actions.html.erb @@ -98,7 +98,7 @@ -<% if @variant_number.to_i == 0 && !user_signed_in? && @article.body_markdown.size > 900 %> +<% if !user_signed_in? && @article.body_markdown.size > 900 %> <% cache("below-article-html-variant-#{rand(20)}", expires_in: 8.hours) do %> <% @html_variant = HtmlVariant.find_for_test(@article.cached_tag_list_array, "article_show_below_article_cta") %> <% if @html_variant %> diff --git a/app/views/articles/_sticky_nav.html.erb b/app/views/articles/_sticky_nav.html.erb index 6d5acc60c..ae97d7401 100644 --- a/app/views/articles/_sticky_nav.html.erb +++ b/app/views/articles/_sticky_nav.html.erb @@ -72,63 +72,52 @@ <% end %> - <% if @variant_number.to_i == 1 %> - <% cache("html-variant-sidebar#{rand(300)}", expires_in: 2.hours) do %> - <% @html_variant = HtmlVariant.find_for_test(@article.cached_tag_list_array) %> - <% if @html_variant %> -
- <%= @html_variant.html.html_safe %> + <% cache("article-sticky-nav-articles-#{@article.id}-#{@actor.last_article_at}", expires_in: 48.hours) do %> + <% @sticky_collection = StickyArticleCollection.new(@article, @organization || @user) %> + <% @sticky_articles = @sticky_collection.suggested_stickies %> + <% @user_stickies = @sticky_collection.user_stickies %> + <% if @user_stickies.any? %> + <% @user_stickies.each_with_index do |article, index| %> +
+ <% if index == 0 %> +
+ <% if @actor.username.size < 18 %> + More from @<%= @actor.username %> + <% else %> + More from
@<%= @actor.username %> + <% end %> +
+ <% end %> + + <%= article.user.name %> profile image + <%= article.title %> +
+ <% article.decorate.cached_tag_list_array.each do |tag| %> + #<%= tag %> + <% end %> +
+
<% end %> <% end %> - <% else %> - <% cache("article-sticky-nav-articles-#{@article.id}-#{@actor.last_article_at}", expires_in: 48.hours) do %> - <% @sticky_collection = StickyArticleCollection.new(@article, @organization || @user) %> - <% @sticky_articles = @sticky_collection.suggested_stickies %> - <% @user_stickies = @sticky_collection.user_stickies %> - <% if @user_stickies.any? %> - <% @user_stickies.each_with_index do |article, index| %> -
- <% if index == 0 %> -
- <% if @actor.username.size < 18 %> - More from @<%= @actor.username %> - <% else %> - More from
@<%= @actor.username %> - <% end %> -
- <% end %> - - <%= article.user.name %> profile image - <%= article.title %> -
- <% article.decorate.cached_tag_list_array.each do |tag| %> - #<%= tag %> - <% end %> -
-
-
- <% end %> - <% end %> - <% if @sticky_articles %> - <% @sticky_articles.each_with_index do |article, index| %> -
- <% if index == 0 %> -
- " alt="Fire emoji" loading="lazy"> Trending on <%= community_name %> -
- <% end %> - - <%= article.user.name %> profile image - <%= article.title %> -
- <% article.decorate.cached_tag_list_array.each do |tag| %> - #<%= tag %> - <% end %> -
-
-
- <% end %> + <% if @sticky_articles %> + <% @sticky_articles.each_with_index do |article, index| %> +
+ <% if index == 0 %> +
+ " alt="Fire emoji" loading="lazy"> Trending on <%= community_name %> +
+ <% end %> + + <%= article.user.name %> profile image + <%= article.title %> +
+ <% article.decorate.cached_tag_list_array.each do |tag| %> + #<%= tag %> + <% end %> +
+
+
<% end %> <% end %> <% end %> diff --git a/app/views/articles/show.html.erb b/app/views/articles/show.html.erb index eb18c9587..982b71f33 100644 --- a/app/views/articles/show.html.erb +++ b/app/views/articles/show.html.erb @@ -205,7 +205,7 @@ <% end %>
-<% stick_nav_cache_key = "sticky-sidebar-#{@article.id}-#{(@organization || @user).profile_updated_at}-#{(@organization || @user).last_article_at}-#{@variant_number}-#{@user.pro?}" %> +<% stick_nav_cache_key = "sticky-sidebar-#{@article.id}-#{(@organization || @user).profile_updated_at}-#{(@organization || @user).last_article_at}-0-#{@user.pro?}" %> <% cache(stick_nav_cache_key, expires_in: 50.hours) do %> <%= render "articles/sticky_nav" %> <% end %> diff --git a/app/views/html_variants/_form.html.erb b/app/views/html_variants/_form.html.erb index 025eda095..48786b869 100644 --- a/app/views/html_variants/_form.html.erb +++ b/app/views/html_variants/_form.html.erb @@ -25,7 +25,7 @@ <%= f.label :published %> <%= f.check_box :published %> <%= f.label :group %> - <%= f.select(:group, options_for_select(HtmlVariant::GROUP_NAMES, @html_variant.group || "article_show_sidebar_cta")) %> + <%= f.select(:group, options_for_select(HtmlVariant::GROUP_NAMES, @html_variant.group || "article_show_below_article_cta")) %> <%= f.submit %> <% end %> diff --git a/app/views/html_variants/index.html.erb b/app/views/html_variants/index.html.erb index 825050941..485dcacf9 100644 --- a/app/views/html_variants/index.html.erb +++ b/app/views/html_variants/index.html.erb @@ -7,7 +7,6 @@