field_test 0.5.3 → 0.5.5

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: fdb76c20b686424fab97716c260d114977a33ca9d9b41f8ba03a25523742fb49
4
- data.tar.gz: 1879b26b2b96ce4083a66f41d15abf07ab61eb2d264308076a65a79adb319df2
3
+ metadata.gz: f9182763b694b61f732e994e50f0b18f86d60fed181d302f885cd850f19831ae
4
+ data.tar.gz: b5c0e167d8f0e942dad04fd19f565ec54f38593b6cb4501c5a8631670046dc39
5
5
  SHA512:
6
- metadata.gz: 2167ced106ba8f40dc2b8eab444101b7e422722daee96f9b19cee3e596fb22ac18fd6999f8afc9f454e496fffa3fd403cdfefca4d36d32d4601148745b507832
7
- data.tar.gz: 440498c252008895b164cb59214ef3f98cf4d31572694df985f62a5393c66abd71c8dcb56a57ddb4cff346b227cff1e4d9f8d18c79c375996de53efaa0031ba0
6
+ metadata.gz: cde68d5e3a16b45e2d29e25c2bbf7fc74190bc69a7ef11477b808619d54764f1107f254ac9eea893468c48678bb64545cf99ca2d57ee3f570335210f12c4e08a
7
+ data.tar.gz: 9e82ce617955680184e3a79c01d1028e50a0a07ff26a6751cfffb47a68345223762742f41f40741ff52bd75e85c9706c845d438b4302544f5c923cdc211d6070
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## 0.5.5 (2023-01-29)
2
+
3
+ - Added warning for non-string variants
4
+
5
+ ## 0.5.4 (2022-06-16)
6
+
7
+ - Fixed bug in results with MySQL and multiple goals (again)
8
+
1
9
  ## 0.5.3 (2022-05-26)
2
10
 
3
11
  - Fixed bug in results with MySQL and multiple goals
data/README.md CHANGED
@@ -332,76 +332,6 @@ Now you can do:
332
332
  user.field_test_memberships
333
333
  ```
334
334
 
335
- ## Upgrading
336
-
337
- ### 0.3.0
338
-
339
- Upgrade the gem and add to `config/field_test.yml`:
340
-
341
- ```yml
342
- legacy_participants: true
343
- ```
344
-
345
- Also, if you use Field Test in emails, know that the default way participants are determined has changed. Restore the previous way with:
346
-
347
- ```ruby
348
- class ApplicationMailer < ActionMailer::Base
349
- def field_test_participant
350
- message.to.first
351
- end
352
- end
353
- ```
354
-
355
- We also recommend upgrading participants when you have time.
356
-
357
- #### Upgrading Participants
358
-
359
- Field Test 0.3.0 splits the `field_test_memberships.participant` column into `participant_type` and `participant_id`.
360
-
361
- To upgrade without downtime, create a migration:
362
-
363
- ```sh
364
- rails generate migration upgrade_field_test_participants
365
- ```
366
-
367
- with:
368
-
369
- ```ruby
370
- class UpgradeFieldTestParticipants < ActiveRecord::Migration[6.0]
371
- def change
372
- add_column :field_test_memberships, :participant_type, :string
373
- add_column :field_test_memberships, :participant_id, :string
374
-
375
- add_index :field_test_memberships, [:participant_type, :participant_id, :experiment],
376
- unique: true, name: "index_field_test_memberships_on_participant_and_experiment"
377
- end
378
- end
379
- ```
380
-
381
- After you run it, writes will go to both the old and new sets of columns.
382
-
383
- Next, backfill data:
384
-
385
- ```ruby
386
- FieldTest::Membership.where(participant_id: nil).find_each do |membership|
387
- participant = membership.participant
388
-
389
- if participant.include?(":")
390
- participant_type, _, participant_id = participant.rpartition(":")
391
- participant_type = nil if participant_type == "cookie" # legacy
392
- else
393
- participant_id = participant
394
- end
395
-
396
- membership.update!(
397
- participant_type: participant_type,
398
- participant_id: participant_id
399
- )
400
- end
401
- ```
402
-
403
- Finally, remove `legacy_participants: true` from the config file. Once you confirm it’s working, you can drop the `participant` column (you can rename it first just to be extra safe).
404
-
405
335
  ## Credits
406
336
 
407
337
  A huge thanks to [Evan Miller](https://www.evanmiller.org/) for deriving the Bayesian formulas.
@@ -8,6 +8,11 @@ module FieldTest
8
8
  @name = attributes[:name] || @id.to_s.titleize
9
9
  @description = attributes[:description]
10
10
  @variants = attributes[:variants]
11
+ if @variants.any? { |v| !v.is_a?(String) }
12
+ # TODO add support for more types (including query parameters)
13
+ # or raise error in 0.6
14
+ warn "[field_test] Only string variants are supported (#{id})"
15
+ end
11
16
  @weights = @variants.size.times.map { |i| attributes[:weights].to_a[i] || 1 }
12
17
  @winner = attributes[:winner]
13
18
  @closed = attributes[:closed]
@@ -113,9 +118,10 @@ module FieldTest
113
118
  :participant
114
119
  elsif adapter_name =~ /postg/i # postgres
115
120
  "(participant_type, participant_id)"
121
+ elsif adapter_name =~ /mysql/i
122
+ "COALESCE(participant_type, ''), participant_id"
116
123
  else
117
124
  # SQLite supports single column
118
- # MySQL supports multiple columns, but none can be NULL
119
125
  "COALESCE(participant_type, '') || ':' || participant_id"
120
126
  end
121
127
 
@@ -1,3 +1,3 @@
1
1
  module FieldTest
2
- VERSION = "0.5.3"
2
+ VERSION = "0.5.5"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: field_test
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.3
4
+ version: 0.5.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-05-27 00:00:00.000000000 Z
11
+ date: 2023-01-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -124,7 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
124
124
  - !ruby/object:Gem::Version
125
125
  version: '0'
126
126
  requirements: []
127
- rubygems_version: 3.3.7
127
+ rubygems_version: 3.4.1
128
128
  signing_key:
129
129
  specification_version: 4
130
130
  summary: A/B testing for Rails