Class: Experiment

Inherits:
ApplicationRecord show all
Defined in:
app/models/experiment.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ApplicationRecord

at_most, id_in, id_not_in, iid_in, pluck_primary_key, primary_key_in, safe_ensure_unique, safe_find_or_create_by, safe_find_or_create_by!, underscore, without_order

Class Method Details

.add_user(name, group_type, user) ⇒ Object


11
12
13
14
15
16
17
18
# File 'app/models/experiment.rb', line 11

def self.add_user(name, group_type, user)
  experiment = find_or_create_by(name: name)

  return unless experiment
  return if experiment.experiment_users.where(user: user).exists?

  group_type == ::Gitlab::Experimentation::GROUP_CONTROL ? experiment.add_control_user(user) : experiment.add_experimental_user(user)
end

Instance Method Details

#add_control_user(user) ⇒ Object


20
21
22
# File 'app/models/experiment.rb', line 20

def add_control_user(user)
  control_group_users << user
end

#add_experimental_user(user) ⇒ Object


24
25
26
# File 'app/models/experiment.rb', line 24

def add_experimental_user(user)
  experimental_group_users << user
end