splut 0.0.1 → 0.0.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 63f7aee30ef4c49e78226f4adf3fa3b81f80cc6d530210588915e1a8686cb660
4
- data.tar.gz: a1e4eea2407a15836f7e85070ebd8bffaafcdfc33a163ed1a3d5b38fed4fe27f
3
+ metadata.gz: 2e0870a17a1642759d572c7417d4ce1e482cfbabedaae9a63a22a76810622b3e
4
+ data.tar.gz: ff87becf1d51811269966fb282f95b0b6d4497d6113522db023c462571b81b51
5
5
  SHA512:
6
- metadata.gz: 3bab50c05a714608459eb4e9438d002a1d708f54ef3f612938fe0d3b1ef27ed9f7508030eda6066259d8573a67e617fc8d91080741e43cf533a82ab8796d3020
7
- data.tar.gz: 2ed3375c2b39139cd73c08381b1d10456a40f8f2a161caa3a8b0e179b5dc6d93f88749309cde9a58f75da56d89c1e0c2ec31ae699397b9d24b5f0a69bd28cf3b
6
+ metadata.gz: 244db7966070409bf04102ac1d6c1fb3835929f3d51d4f12ddc5ce9456485cce27778f26dbbabf78259f2a1a7646ef1247143a38d7f4bce940276bcbb0773acd
7
+ data.tar.gz: c7e80e9e41fa660392dcb8a9da2b59c90c5616a82b00378427d23fb92b5ab7b5e08cea605168e025ce627222ef234f3804fc2d1392815a5f44d84b34ef07d484
@@ -12,14 +12,34 @@ module Splut
12
12
  # but will not segement them
13
13
  end
14
14
 
15
- def retrieve_group!(splutable_thing)
15
+ def participate!(splutable_thing)
16
16
  # will return the segment participant if the
17
17
  # thing is already in the experiment
18
18
  #
19
19
  #
20
20
  # will put the participant into the experiment if not
21
- end
21
+ #
22
+ segment_participant = Splut::SegmentParticipant.find_by(
23
+ variation_id: self.variations.collect(&:id),
24
+ splutable: splutable_thing)
25
+
26
+ if !segment_participant
27
+ random = rand(self.variations.count).floor
28
+
29
+ this_variation = self.variations[random]
22
30
 
31
+ puts "Putting #{splutable_thing} into variation #{this_variation}"
32
+ segment_participant = this_variation.segment_participants.create!(splutable: splutable_thing)
23
33
 
34
+ else
35
+ puts " #{splutable_thing} was already in variation #{this_variation}"
36
+ this_variation = segment_participant.variation
37
+ end
38
+
39
+ impression = this_variation.impressions.create!(splutable: splutable_thing,
40
+ segment_participant: segment_participant)
41
+
42
+ impression
43
+ end
24
44
  end
25
45
  end
@@ -8,7 +8,7 @@ module Splut
8
8
  belongs_to :variation
9
9
 
10
10
  belongs_to :splutable, polymorphic: true
11
-
11
+ belongs_to :segment_participant
12
12
 
13
13
  counter_culture :variation, column_name: '_impression_total'
14
14
  counter_culture :variation, column_name: proc {|model| model.success ? '_impression_success' : nil }
@@ -2,7 +2,7 @@
2
2
  require 'counter_culture'
3
3
 
4
4
  module Splut
5
- class SegementParticipant < ActiveRecord::Base
5
+ class SegmentParticipant < ActiveRecord::Base
6
6
  self.table_name = "segment_participants"
7
7
 
8
8
  belongs_to :variation
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Splut
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: splut
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Fleetwood-Boldt
@@ -78,7 +78,7 @@ files:
78
78
  - lib/splut.rb
79
79
  - lib/splut/models/experiment.rb
80
80
  - lib/splut/models/impression.rb
81
- - lib/splut/models/segement_participant.rb
81
+ - lib/splut/models/segment_participant.rb
82
82
  - lib/splut/models/variation.rb
83
83
  - lib/version.rb
84
84
  homepage: https://heliosdev.shop/splut/