split-export 1.1.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Readme.mdown +8 -0
- data/lib/split/export.rb +47 -3
- data/lib/split/export/version.rb +1 -1
- data/spec/export_spec.rb +16 -6
- data/split-export.gemspec +1 -1
- metadata +4 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5a3924dc7806addaed71fd465447688c864c6c19
|
4
|
+
data.tar.gz: d58689307780d65717c55729771986f78a942a4a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fafaabcf0f9e880e6954a99782fa2fdec20f11e84741a375c563a021a4d56345b50778f1099659300c62c6b0279bdefea03351a4bbaefeb1ef9e8a4b717b9963
|
7
|
+
data.tar.gz: 8cec501deac0ebced73ea509ce4afcb89ccecde1c776ff9e0cddfbe3abe591c60313965b4b93f184042fb8f45ae5c2122cac00efd4ecdffb9427ed600557e26a
|
data/Readme.mdown
CHANGED
@@ -26,10 +26,18 @@ and require it in your project:
|
|
26
26
|
|
27
27
|
## Usage
|
28
28
|
|
29
|
+
This exports data for all experiments. This data set does not break down conversions by goals:
|
30
|
+
|
29
31
|
require 'split/export'
|
30
32
|
csv_data = Split::Export.to_csv
|
31
33
|
File.open('path/to/my.csv', 'w') {|f| f.write(csv_data) }
|
32
34
|
|
35
|
+
This exports data for a single experiment, and breaks it down by group and goal:
|
36
|
+
|
37
|
+
require 'split/export'
|
38
|
+
csv_data = Split::Export.experiment_to_csv("my_experiment")
|
39
|
+
File.open('path/to/my.csv', 'w') {|f| f.write(csv_data) }
|
40
|
+
|
33
41
|
## Development
|
34
42
|
|
35
43
|
Source hosted at [GitHub](http://github.com/splitrb/split-export).
|
data/lib/split/export.rb
CHANGED
@@ -10,17 +10,61 @@ module Split
|
|
10
10
|
BigDecimal.new(number.to_s).round(precision).to_f
|
11
11
|
end
|
12
12
|
|
13
|
+
# this method calculates the z_score for an alternative including all goals. This behavior should
|
14
|
+
# be added to Alternative#z_score but until then, this method will do. I lifted most of the code from that method.
|
15
|
+
def z_score_all_goals(alternative)
|
16
|
+
goals = alternative.goals + [nil]
|
17
|
+
control = alternative.experiment.control
|
18
|
+
|
19
|
+
return 'N/A' if control.name == alternative.name
|
20
|
+
|
21
|
+
p_a = goals.inject(0) { |sum, g| sum + alternative.conversion_rate(g) }
|
22
|
+
p_c = goals.inject(0) { |sum, g| sum + control.conversion_rate(g) }
|
23
|
+
|
24
|
+
n_a = alternative.participant_count
|
25
|
+
n_c = control.participant_count
|
26
|
+
|
27
|
+
z_score = Split::Zscore.calculate(p_a, n_a, p_c, n_c)
|
28
|
+
end
|
29
|
+
|
13
30
|
def to_csv
|
14
31
|
csv = CSV.generate do |csv|
|
15
32
|
csv << ['Experiment', 'Alternative', 'Participants', 'Completed', 'Conversion Rate', 'Z score', 'Control', 'Winner']
|
16
33
|
Split::ExperimentCatalog.all.each do |experiment|
|
34
|
+
goals = experiment.goals + [nil] # nil corresponds to conversions without any goals.
|
35
|
+
|
17
36
|
experiment.alternatives.each do |alternative|
|
18
37
|
csv << [experiment.name,
|
19
38
|
alternative.name,
|
20
39
|
alternative.participant_count,
|
21
|
-
alternative.completed_count,
|
22
|
-
round(alternative.conversion_rate, 3),
|
23
|
-
round(alternative
|
40
|
+
goals.inject(0) { |sum, g| sum + alternative.completed_count(g) },
|
41
|
+
round(goals.inject(0) { |sum, g| sum + alternative.conversion_rate(g) }, 3),
|
42
|
+
round(z_score_all_goals(alternative), 3),
|
43
|
+
alternative.control?,
|
44
|
+
alternative.to_s == experiment.winner.to_s]
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def experiment_to_csv(experiment)
|
51
|
+
csv = CSV.generate do |csv|
|
52
|
+
csv << ["Alternative", "Goal", "Participants", "Completed", "Conversion Rate", "Z Score", "Control", "Winner"]
|
53
|
+
|
54
|
+
experiment = Split::ExperimentCatalog.find(experiment)
|
55
|
+
|
56
|
+
break if !experiment
|
57
|
+
|
58
|
+
goals = [nil] + experiment.goals # nil corresponds to conversions without any goals.
|
59
|
+
|
60
|
+
experiment.alternatives.each do |alternative|
|
61
|
+
goals.each do |goal|
|
62
|
+
csv << [alternative.name,
|
63
|
+
goal,
|
64
|
+
alternative.participant_count,
|
65
|
+
alternative.completed_count(goal),
|
66
|
+
round(alternative.conversion_rate(goal), 3),
|
67
|
+
round(alternative.z_score(goal), 3),
|
24
68
|
alternative.control?,
|
25
69
|
alternative.to_s == experiment.winner.to_s]
|
26
70
|
end
|
data/lib/split/export/version.rb
CHANGED
data/spec/export_spec.rb
CHANGED
@@ -2,18 +2,28 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Split::Export do
|
4
4
|
before :each do
|
5
|
-
experiment = Split::ExperimentCatalog.find_or_create('link_color', 'blue', 'red', 'green')
|
5
|
+
experiment = Split::ExperimentCatalog.find_or_create({'link_color': ["control", "goal"]}, 'blue', 'red', 'green')
|
6
6
|
blue = Split::Alternative.new('blue', 'link_color')
|
7
|
-
blue.participant_count =
|
8
|
-
blue.set_completed_count(
|
7
|
+
blue.participant_count = 50
|
8
|
+
blue.set_completed_count(20, "control")
|
9
|
+
blue.set_completed_count(10, "goal")
|
9
10
|
blue.save
|
10
11
|
red = Split::Alternative.new('red', 'link_color')
|
11
|
-
red.participant_count =
|
12
|
-
red.set_completed_count(
|
12
|
+
red.participant_count = 60
|
13
|
+
red.set_completed_count(10, "control")
|
14
|
+
red.set_completed_count(30, "goal")
|
13
15
|
red.save
|
14
16
|
end
|
15
17
|
|
16
18
|
it "should generate a csv of split data" do
|
17
|
-
Split::Export.to_csv.should eql("Experiment,Alternative,Participants,Completed,Conversion Rate,Z score,Control,Winner\nlink_color,blue,
|
19
|
+
Split::Export.to_csv.should eql("Experiment,Alternative,Participants,Completed,Conversion Rate,Z score,Control,Winner\nlink_color,blue,50,30,0.6,0.0,true,false\nlink_color,red,60,40,0.667,0.724,false,false\nlink_color,green,0,0,0.0,0.0,false,false\n")
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should generate a detailed csv of split data for a single table" do
|
23
|
+
Split::Export.experiment_to_csv("link_color").should eql("Alternative,Goal,Participants,Completed,Conversion Rate,Z Score,Control,Winner\nblue,,50,0,0.0,0.0,true,false\nblue,control,50,20,0.4,0.0,true,false\nblue,goal,50,10,0.2,0.0,true,false\nred,,60,0,0.0,0.0,false,false\nred,control,60,10,0.167,-2.736,false,false\nred,goal,60,30,0.5,3.257,false,false\ngreen,,0,0,0.0,0.0,false,false\ngreen,control,0,0,0.0,0.0,false,false\ngreen,goal,0,0,0.0,0.0,false,false\n")
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should quietly return nil if a bad experiment name is passed in" do
|
27
|
+
Split::Export.experiment_to_csv("incorrect_name").should be_nil
|
18
28
|
end
|
19
29
|
end
|
data/split-export.gemspec
CHANGED
@@ -23,5 +23,5 @@ Gem::Specification.new do |s|
|
|
23
23
|
# Development Dependencies
|
24
24
|
s.add_development_dependency "rspec", "~> 2.6"
|
25
25
|
s.add_development_dependency "rake", "~> 11.1"
|
26
|
-
s.add_development_dependency 'fakeredis', '~> 0.
|
26
|
+
s.add_development_dependency 'fakeredis', '~> 0.6.0'
|
27
27
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: split-export
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Nesbitt
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-12-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: split
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 0.
|
61
|
+
version: 0.6.0
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 0.
|
68
|
+
version: 0.6.0
|
69
69
|
description:
|
70
70
|
email:
|
71
71
|
- andrewnez@gmail.com
|
@@ -111,4 +111,3 @@ summary: Split extension to export your data
|
|
111
111
|
test_files:
|
112
112
|
- spec/export_spec.rb
|
113
113
|
- spec/spec_helper.rb
|
114
|
-
has_rdoc:
|