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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ae90d445d9e578a618a7ff3858edcb00719055716647c6fec0374db385b0b935
|
4
|
+
data.tar.gz: cc51ca7b8093c2b43d5c8610130db5cbbd12811520a57f8cc0b4fe3e114a1eaa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
@@ -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 == :
|
8
|
-
|
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
|
24
|
+
class RandomCycle
|
25
25
|
def initialize(enumerable)
|
26
|
-
@
|
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
|