Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DEMO] A/B test demonstration #101

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
ruby '3.2.2'

gem 'bootsnap', require: false
gem 'cancancan'
gem 'graphql'
gem 'graphql-client'
gem 'http'
Expand All @@ -14,6 +15,7 @@ gem 'puma'
gem 'rails', '~> 7.0'
gem 'sentry-rails'
gem 'sentry-ruby'
gem 'split', require: 'split/dashboard'
gem 'sprockets-rails'
gem 'stimulus-rails'
gem 'turbo-rails'
Expand Down
25 changes: 25 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ GEM
bootsnap (1.18.3)
msgpack (~> 1.2)
builder (3.2.4)
cancancan (3.6.1)
capybara (3.40.0)
addressable
matrix
Expand Down Expand Up @@ -194,6 +195,8 @@ GEM
mocha (2.2.0)
ruby2_keywords (>= 0.0.5)
msgpack (1.7.2)
mustermann (3.0.0)
ruby2_keywords (~> 0.0.1)
mutex_m (0.2.0)
net-imap (0.4.10)
date
Expand Down Expand Up @@ -223,6 +226,9 @@ GEM
nio4r (~> 2.0)
racc (1.7.3)
rack (3.0.10)
rack-protection (4.0.0)
base64 (>= 0.1.0)
rack (>= 3.0.0, < 4)
rack-session (2.0.0)
rack (>= 3.0.0)
rack-test (2.1.0)
Expand Down Expand Up @@ -263,6 +269,10 @@ GEM
rake (13.2.1)
rdoc (6.6.3.1)
psych (>= 4.0.0)
redis (5.2.0)
redis-client (>= 0.22.0)
redis-client (0.22.2)
connection_pool
regexp_parser (2.9.0)
reline (0.5.6)
io-console (~> 0.5)
Expand All @@ -288,6 +298,8 @@ GEM
rubocop-ast (>= 1.31.1, < 2.0)
ruby-progressbar (1.13.0)
ruby2_keywords (0.0.5)
rubystats (0.4.1)
matrix
rubyzip (2.3.2)
sassc (2.4.0)
ffi (~> 1.9)
Expand Down Expand Up @@ -315,6 +327,17 @@ GEM
simplecov-html (0.12.3)
simplecov-lcov (0.8.0)
simplecov_json_formatter (0.1.4)
sinatra (4.0.0)
mustermann (~> 3.0)
rack (>= 3.0.0, < 4)
rack-protection (= 4.0.0)
rack-session (>= 2.0.0, < 3)
tilt (~> 2.0)
split (4.0.4)
matrix
redis (>= 4.2)
rubystats (>= 0.3.0)
sinatra (>= 1.2.6)
sprockets (4.2.1)
concurrent-ruby (~> 1.0)
rack (>= 2.2.4, < 4)
Expand Down Expand Up @@ -373,6 +396,7 @@ DEPENDENCIES
better_errors
binding_of_caller
bootsnap
cancancan
capybara
climate_control
debug
Expand All @@ -396,6 +420,7 @@ DEPENDENCIES
sentry-ruby
simplecov
simplecov-lcov
split
sprockets-rails
sqlite3
stimulus-rails
Expand Down
9 changes: 8 additions & 1 deletion app/assets/stylesheets/partials/_search.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,17 @@

/* basic search bar */
.basic-search {
background-color: #989898;
margin-bottom: 0rem;
padding: 2.4rem 2rem 1.6rem 2rem;

&.standard {
background-color: #989898;
}

&.alt {
background-color: #ffd700;
}

details {
&:first-of-type {
margin-top: 1rem;
Expand Down
4 changes: 4 additions & 0 deletions app/controllers/record_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ class RecordController < ApplicationController

include RecordHelper

def out
url = params[:url]
end

def view
id = params[:id]
index = ENV.fetch('TIMDEX_INDEX', nil)
Expand Down
5 changes: 5 additions & 0 deletions app/controllers/search_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ class SearchController < ApplicationController
end

def results
# if we are loading results, the user submitted the form - so this experiment is finished
ab_finished(:ui_colors)

# ab_test(:result_format)

# inject session preference for boolean type if it is present
params[:booleanType] = cookies[:boolean_type] || 'AND'

Expand Down
32 changes: 32 additions & 0 deletions app/models/ability.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# frozen_string_literal: true

class Ability
include CanCan::Ability

def initialize(user)
# Define abilities for the user here. For example:
#
# return unless user.present?
# can :read, :all
# return unless user.admin?
# can :manage, :all
#
# The first argument to `can` is the action you are giving the user
# permission to do.
# If you pass :manage it will apply to every action. Other common actions
# here are :read, :create, :update and :destroy.
#
# The second argument is the resource the user can perform the action on.
# If you pass :all it will apply to every resource. Otherwise pass a Ruby
# class of the resource.
#
# The third argument is an optional hash of conditions to further filter the
# objects.
# For example, here the user can only update published articles.
#
# can :update, Article, published: true
#
# See the wiki for details:
# https://github.com/CanCanCommunity/cancancan/blob/develop/docs/define_check_abilities.md
end
end
1 change: 1 addition & 0 deletions app/views/record/out.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<p>This would redirect you.</p>
2 changes: 1 addition & 1 deletion app/views/search/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ if params[:geodistance] == "true"
end
%>

<form id="basic-search" class="form-horizontal basic-search" action="<%= results_path %>" method="get" role="search">
<form id="basic-search" class="form-horizontal basic-search <%= ab_test(:ui_colors, "standard", "alt") %>" action="<%= results_path %>" method="get" role="search">
<div class="form-group">
<input id="basic-search-main" type="search"
class="field field-text basic-search-input <%= "required" if search_required %>" name="q"
Expand Down
3 changes: 3 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
get 'issn', to: 'fact#issn'
get 'pmid', to: 'fact#pmid'

get 'out/(:url)', to: 'record#out'
get 'record/(:id)',
to: 'record#view',
as: 'record',
Expand All @@ -15,4 +16,6 @@
get 'style-guide', to: 'static#style_guide'

get 'boolpref', to: 'static#boolpref'

mount Split::Dashboard, at: 'split'
end
Loading