experimental 0.2.5 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/experimental/experiment.rb +16 -3
- data/lib/experimental/loader.rb +9 -2
- data/lib/experimental/middleware.rb +11 -0
- data/lib/experimental/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1cbc23d7d4d559525acef4a4a02acc8f6129dddc
|
4
|
+
data.tar.gz: c90758e9493e4c965af09a9d0dc98c58d7fb4e53
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8915404bdb3ce651853d2002598b113612561a87414062f97b8a3ef177beeac52cf6d203509c18d0af1ba2ba0506221a9468397f769362a647e9ebe3e1451e3e
|
7
|
+
data.tar.gz: 539a9ba09dc190a9983e1c558efff665f88759badd8e727a767154448f625e4b9d6d04c40597755c1cc44565f1a92ada9cc2ca897f8561ab3452b0622bfdd67f
|
@@ -42,7 +42,7 @@ module Experimental
|
|
42
42
|
winning_bucket
|
43
43
|
elsif Experimental.overrides.include?(subject, name)
|
44
44
|
Experimental.overrides[subject, name]
|
45
|
-
|
45
|
+
elsif started?
|
46
46
|
bucket_number(subject)
|
47
47
|
end
|
48
48
|
end
|
@@ -63,6 +63,14 @@ module Experimental
|
|
63
63
|
save
|
64
64
|
end
|
65
65
|
|
66
|
+
def unstart
|
67
|
+
self.start_date = nil
|
68
|
+
self.end_date = nil
|
69
|
+
self.removed_at = nil
|
70
|
+
self.winning_bucket = nil
|
71
|
+
save
|
72
|
+
end
|
73
|
+
|
66
74
|
def restart
|
67
75
|
return unless ended?
|
68
76
|
|
@@ -90,12 +98,16 @@ module Experimental
|
|
90
98
|
!removed_at.nil?
|
91
99
|
end
|
92
100
|
|
101
|
+
def started?
|
102
|
+
start_date.present? && start_date <= Time.now
|
103
|
+
end
|
104
|
+
|
93
105
|
def ended?
|
94
106
|
!end_date.nil? && Time.now > end_date
|
95
107
|
end
|
96
108
|
|
97
109
|
def active?
|
98
|
-
!removed? && !ended?
|
110
|
+
!removed? && started? && !ended?
|
99
111
|
end
|
100
112
|
|
101
113
|
def self.available
|
@@ -103,7 +115,8 @@ module Experimental
|
|
103
115
|
end
|
104
116
|
|
105
117
|
def self.active
|
106
|
-
|
118
|
+
now = Time.now
|
119
|
+
available.where('start_date < ? AND end_date IS NULL OR ? <= end_date', now, now)
|
107
120
|
end
|
108
121
|
|
109
122
|
def to_sql_formula(subject_table = "users")
|
data/lib/experimental/loader.rb
CHANGED
@@ -14,10 +14,17 @@ module Experimental
|
|
14
14
|
Experimental::Experiment.transaction do
|
15
15
|
active = Experimental.experiment_data.map do |name, attributes|
|
16
16
|
experiment = Experimental::Experiment.find_or_initialize_by_name(name)
|
17
|
-
|
17
|
+
|
18
|
+
unstarted = attributes.delete('unstarted')
|
18
19
|
defaults = {'num_buckets' => nil, 'notes' => nil, 'population' => nil}
|
19
20
|
experiment.assign_attributes(defaults.merge(attributes))
|
20
|
-
|
21
|
+
if unstarted
|
22
|
+
experiment.start_date = nil
|
23
|
+
else
|
24
|
+
experiment.start_date ||= Time.current
|
25
|
+
end
|
26
|
+
|
27
|
+
logger.info " * #{experiment.id ? 'updating' : 'creating'} #{name}"
|
21
28
|
experiment.tap(&:save!)
|
22
29
|
end
|
23
30
|
|
data/lib/experimental/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: experimental
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- HowAboutWe.com
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2014-
|
14
|
+
date: 2014-04-08 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: rails
|
@@ -65,6 +65,7 @@ files:
|
|
65
65
|
- lib/experimental/controller_actions.rb
|
66
66
|
- lib/experimental/engine.rb
|
67
67
|
- lib/experimental/loader.rb
|
68
|
+
- lib/experimental/middleware.rb
|
68
69
|
- lib/experimental/overrides.rb
|
69
70
|
- lib/experimental/railtie.rb
|
70
71
|
- lib/experimental/rspec_helpers.rb
|
@@ -103,7 +104,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
103
104
|
version: '0'
|
104
105
|
requirements: []
|
105
106
|
rubyforge_project:
|
106
|
-
rubygems_version: 2.2.
|
107
|
+
rubygems_version: 2.2.2
|
107
108
|
signing_key:
|
108
109
|
specification_version: 4
|
109
110
|
summary: Adds support for database-backed AB tests in Rails apps
|