splut 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2e0870a17a1642759d572c7417d4ce1e482cfbabedaae9a63a22a76810622b3e
4
- data.tar.gz: ff87becf1d51811269966fb282f95b0b6d4497d6113522db023c462571b81b51
3
+ metadata.gz: 68c305af3255702202f540d3fbfb48884f6534a40a35a919860c32d5eb5510d4
4
+ data.tar.gz: 1f49ff4e1776c996c76aea31e6e15e5f6368ae80f07b2bec0a74940394545535
5
5
  SHA512:
6
- metadata.gz: 244db7966070409bf04102ac1d6c1fb3835929f3d51d4f12ddc5ce9456485cce27778f26dbbabf78259f2a1a7646ef1247143a38d7f4bce940276bcbb0773acd
7
- data.tar.gz: c7e80e9e41fa660392dcb8a9da2b59c90c5616a82b00378427d23fb92b5ab7b5e08cea605168e025ce627222ef234f3804fc2d1392815a5f44d84b34ef07d484
6
+ metadata.gz: 6db83b5bc8a491e9c2118b9c695a39c81560a0fe1f9f18d2587fc3ef57a2f5df4d59c0f0403766151b0dbcecada88f65a34f13ba96a3ca279c1f5abb673c7aa8
7
+ data.tar.gz: 6d06e3deb5058cdcba53634200b4002a37953ace0d72f29edd2411ea102f3cf747866c5df75a7cdb677338a97f23ee3149ab04ed496c9d2fb9203f601f4c406f
@@ -13,9 +13,9 @@ class CreateSplutTables < ActiveRecord::Migration<%= migration_version %>
13
13
  t.string :name
14
14
  t.string :letter_designation
15
15
  t.integer :_impression_total, default: 0, null: false
16
- t.integer :_segmentation_total, default: 0, null: false
16
+ t.integer :_segment_total, default: 0, null: false
17
17
  t.integer :_impression_success, default: 0, null: false
18
- t.integer :_segmentation_success, default: 0, null: false
18
+ t.integer :_segment_success, default: 0, null: false
19
19
 
20
20
  t.timestamps
21
21
  end
@@ -8,11 +8,16 @@ module Splut
8
8
 
9
9
 
10
10
  def is_in_group?(splutable_thing)
11
- # only checks to see if they are already segemented
12
- # but will not segement them
11
+ existing_segment_participant = SegmentParticipant.find_by(variation_id: self.variations.collect(&:id),
12
+ splutable: splutable_thing)
13
+
13
14
  end
14
15
 
15
16
  def participate!(splutable_thing)
17
+
18
+ if self.variations.none?
19
+ raise "participate! was called on experiment #{self.name} (id #{self.id} but there are no variations)"
20
+ end
16
21
  # will return the segment participant if the
17
22
  # thing is already in the experiment
18
23
  #
@@ -29,6 +34,7 @@ module Splut
29
34
  this_variation = self.variations[random]
30
35
 
31
36
  puts "Putting #{splutable_thing} into variation #{this_variation}"
37
+
32
38
  segment_participant = this_variation.segment_participants.create!(splutable: splutable_thing)
33
39
 
34
40
  else
@@ -7,16 +7,15 @@ module Splut
7
7
 
8
8
  belongs_to :variation
9
9
  belongs_to :splutable, polymorphic: true
10
+ has_many :impressions
10
11
 
11
12
  counter_culture :variation, column_name: :_segment_total
12
13
  counter_culture :variation, column_name: proc {|model| model.success ? '_segment_success' : nil }
13
14
 
14
15
  def success!
15
- # since we don't know the impression, just guess
16
- # that the last impression was the successful one
17
- #
18
- #
19
- # set this + the last impression to successful
16
+
17
+ self.update(success: true, success_at: DateTime.current)
18
+ self.impressions.last.update(success: true, success_at: DateTime.current)
20
19
  end
21
20
  end
22
21
  end
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Splut
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: splut
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Fleetwood-Boldt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-01-11 00:00:00.000000000 Z
11
+ date: 2022-01-14 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: rails
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">"
18
- - !ruby/object:Gem::Version
19
- version: '5.1'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">"
25
- - !ruby/object:Gem::Version
26
- version: '5.1'
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: counter_culture
29
15
  requirement: !ruby/object:Gem::Requirement