Class: DataDuck::Optimizely::Experiments
Instance Attribute Summary
Attributes inherited from Table
#data, #errors
Instance Method Summary
collapse
#optimizely_api_token, #should_fully_reload?
Methods inherited from Table
#actions, #batch_size, #building_name, #check_table_valid!, #distribution_key, #etl!, #extract_by_clause, #extract_by_column, #extract_query, #include_with_all?, #limit_clause, #load!, #name, output, #output_column_names, #output_schema, #prefix, #recreate!, #should_fully_reload?, #show, source, #staging_name, #transform!, transforms, validates
Instance Method Details
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/integrations/optimizely/experiments.rb', line 14
def (destination, options = {})
self.data = []
projects_response = Typhoeus.get("https://www.optimizelyapis.com/experiment/v1/projects", headers: {'Token' => self.optimizely_api_token})
if projects_response.response_code != 200
raise Exception.new("Optimizely API for projects returned error #{ response.response_code} #{ response.body }")
end
projects = Oj.load(projects_response.body)
projects.each do |project|
self.(project["id"])
end
end
|
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/integrations/optimizely/experiments.rb', line 28
def (project_id)
now = DateTime.now
response = Typhoeus.get("https://www.optimizelyapis.com/experiment/v1/projects/#{ project_id }/experiments", headers: {'Token' => self.optimizely_api_token})
if response.response_code != 200
raise Exception.new("Optimizely API for experiments returned error #{ response.response_code} #{ response.body }")
end
experiments = Oj.load(response.body)
experiments.each do |experiment|
experiment[:dataduck_extracted_at] = now
experiment[:project_id] = project_id
end
self.data.concat(experiments)
end
|
#indexes ⇒ Object
65
66
67
|
# File 'lib/integrations/optimizely/experiments.rb', line 65
def indexes
["id", "project_id", "primary_goal_id", "name"]
end
|
#parse_datetimes(row) ⇒ Object
46
47
48
49
50
51
|
# File 'lib/integrations/optimizely/experiments.rb', line 46
def parse_datetimes(row)
row["created"] = DateTime.parse(row["created"])
row["last_modified"] = DateTime.parse(row["last_modified"])
row
end
|
#percentage_included_to_float(row) ⇒ Object
59
60
61
62
63
|
# File 'lib/integrations/optimizely/experiments.rb', line 59
def percentage_included_to_float(row)
row['percentage_included'] = row['percentage_included'].to_i / 100.0
row
end
|
#rename_description_to_name ⇒ Object
53
54
55
56
57
|
# File 'lib/integrations/optimizely/experiments.rb', line 53
def rename_description_to_name
row[:name] = row['description']
row
end
|