active_record_data_loader 1.3.0 → 1.3.1

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: 19d357e3af1a3864a020996df4da4d1d4d710dccd15e50cc10c30f0498acb64b
4
- data.tar.gz: 7a706dcaa17777c1fa93090212385fcd18742d84099663d9555e54452c046595
3
+ metadata.gz: ae90d445d9e578a618a7ff3858edcb00719055716647c6fec0374db385b0b935
4
+ data.tar.gz: cc51ca7b8093c2b43d5c8610130db5cbbd12811520a57f8cc0b4fe3e114a1eaa
5
5
  SHA512:
6
- metadata.gz: 6b541ceb75b06c6152184ae4f9d66e6a1268a8a758c23ce959fb608a78a7860c8f17596fd90b5a9bbadf0853c2d2009b8b68304e6f852d4eed2a3e5ddd1b59d1
7
- data.tar.gz: 509fce080286cae5770bbe6b42ace34b34f1804c8834114d7c0fbbd2e0323b2c785fde4188de6d7221666fd6489eb8229a76c47fea90cddcd96bf3628260c5e8
6
+ metadata.gz: be8f649f5b1240b081b20ce713c2da69596d278db2cf19009916dcaeac3e73493745114c6ec662b90b0ff18ad068f0c881fb345ff68cb15c54497cf97a5ec325
7
+ data.tar.gz: 490223f97f751eedcaad7de58846a01a5ff08a38762f30a9040b6dd65b05b2c2e5ac9fc71683f52ac8986a5c7c7748258904f6b380370813380a7e136581b4df
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Change log
2
2
 
3
+ ## [v1.3.1] - 2021-12-10
4
+
5
+ [Diff](https://github.com/abeiderman/active_record_data_loader/compare/v1.3.0...v1.3.1)
6
+
7
+ ### Changes:
8
+ * Fix bug with cycling through foreign key IDs when multiple foreign keys are in a unique index/constraint. It was cycling all foreign keys in the same order which meant that if a duplicate row was generated then it will continue to be generated. By shuffling the list of foreign key IDs after each cycle, it gives it a chance at coming up with unique values during retries.
9
+
3
10
  ## [v1.3.0] - 2021-12-10
4
11
 
5
12
  [Diff](https://github.com/abeiderman/active_record_data_loader/compare/v1.2.0...v1.3.0)
@@ -49,3 +56,4 @@ Initial stable release
49
56
  [v1.1.0]: https://github.com/abeiderman/active_record_data_loader/releases/tag/v1.1.0
50
57
  [v1.2.0]: https://github.com/abeiderman/active_record_data_loader/releases/tag/v1.2.0
51
58
  [v1.3.0]: https://github.com/abeiderman/active_record_data_loader/releases/tag/v1.3.0
59
+ [v1.3.1]: https://github.com/abeiderman/active_record_data_loader/releases/tag/v1.3.1
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- active_record_data_loader (1.3.0)
4
+ active_record_data_loader (1.3.1)
5
5
  activerecord (>= 5.0)
6
6
 
7
7
  GEM
@@ -4,8 +4,8 @@ module ActiveRecordDataLoader
4
4
  module ActiveRecord
5
5
  class List
6
6
  def self.for(enumerable, strategy: :random)
7
- if strategy == :cycle
8
- Cycle.new(enumerable)
7
+ if strategy == :random_cycle
8
+ RandomCycle.new(enumerable)
9
9
  else
10
10
  Random.new(enumerable)
11
11
  end
@@ -21,13 +21,25 @@ module ActiveRecordDataLoader
21
21
  end
22
22
  end
23
23
 
24
- class Cycle
24
+ class RandomCycle
25
25
  def initialize(enumerable)
26
- @list = enumerable.cycle
26
+ @enumerable = enumerable
27
+ @count = enumerable.count
28
+ reset_list
27
29
  end
28
30
 
29
31
  def next
30
- @list.next
32
+ value = @list.next
33
+ reset_list if (@index += 1) >= @count
34
+ value
35
+ end
36
+
37
+ private
38
+
39
+ def reset_list
40
+ @index = 0
41
+ @enumerable = @enumerable.shuffle
42
+ @list = @enumerable.cycle
31
43
  end
32
44
  end
33
45
  end
@@ -133,7 +133,7 @@ module ActiveRecordDataLoader
133
133
 
134
134
  def column_config_strategy(column)
135
135
  if @index_tracker.contained_in_index?(column)
136
- :cycle
136
+ :random_cycle
137
137
  else
138
138
  :random
139
139
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActiveRecordDataLoader
4
- VERSION = "1.3.0"
4
+ VERSION = "1.3.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_record_data_loader
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alejandro Beiderman