From 397fe1eb2d41d8b4a91e8e55b805b35de3b3df1b Mon Sep 17 00:00:00 2001 From: Rosa Fox Date: Tue, 9 May 2023 16:08:52 +0100 Subject: [PATCH] AA test for Search Results The purpose of the A/A test is to test the % of allocation of traffic/sample population based on the current version of elastic (6.7) against itself. A (ES 6.7) vs A (ES6.7). The A/A is solely to identify how the approach allocates traffic. This will provide benchmark data to aid analysis in future AA tests. This test is only applied to /search/all results, not to finder search results. --- .../ab_tests/elastic_search_aa_testable.rb | 19 ++++++++ app/controllers/finders_controller.rb | 7 ++- app/views/finders/_show_header.html.erb | 6 +++ app/views/layouts/finder_layout.html.erb | 1 + spec/controllers/finders_controller_spec.rb | 47 +++++++++++++++++++ 5 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 app/controllers/ab_tests/elastic_search_aa_testable.rb diff --git a/app/controllers/ab_tests/elastic_search_aa_testable.rb b/app/controllers/ab_tests/elastic_search_aa_testable.rb new file mode 100644 index 000000000..4dda8e9c6 --- /dev/null +++ b/app/controllers/ab_tests/elastic_search_aa_testable.rb @@ -0,0 +1,19 @@ +module AbTests::ElasticSearchAaTestable + def elastic_search_aa_test + GovukAbTesting::AbTest.new( + "EsSixPointSeven", + dimension: 41, + allowed_variants: %w[A B Z], + control_variant: "Z", + ) + end + + def page_under_test? + request.path.include?("/search/all") + end + + def set_requested_variant + @requested_variant = elastic_search_aa_test.requested_variant(request.headers) + @requested_variant.configure_response(response) + end +end diff --git a/app/controllers/finders_controller.rb b/app/controllers/finders_controller.rb index 2aae040cf..bef8ceaa0 100644 --- a/app/controllers/finders_controller.rb +++ b/app/controllers/finders_controller.rb @@ -1,5 +1,6 @@ class FindersController < ApplicationController layout "finder_layout" + include AbTests::ElasticSearchAaTestable before_action do set_expiry(content_item) @@ -8,6 +9,10 @@ class FindersController < ApplicationController def show slimmer_template "gem_layout_full_width" if i_am_a_topic_page_finder + if page_under_test? + set_requested_variant + end + respond_to do |format| format.html do raise UnsupportedContentItem unless content_item.is_finder? @@ -58,7 +63,7 @@ class UnsupportedContentItem < StandardError; end attr_reader :search_query - helper_method :facet_tags, :i_am_a_topic_page_finder, :result_set_presenter, :content_item, :signup_links, :filter_params, :facets + helper_method :facet_tags, :i_am_a_topic_page_finder, :result_set_presenter, :content_item, :signup_links, :filter_params, :facets, :page_under_test? def redirect_to_destination @redirect = content_item.redirect diff --git a/app/views/finders/_show_header.html.erb b/app/views/finders/_show_header.html.erb index e7778e12a..62b36df0d 100644 --- a/app/views/finders/_show_header.html.erb +++ b/app/views/finders/_show_header.html.erb @@ -66,6 +66,12 @@ <% end %> + <% if page_under_test? %> + <% content_for :meta_tags do %> + <%= @requested_variant.analytics_meta_tag.html_safe %> + <% end %> + <% end %> + <% if content_item.summary %>