job-iteration 1.5.0 → 1.5.1
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 +4 -4
- data/CHANGELOG.md +3 -0
- data/Gemfile.lock +1 -1
- data/lib/job-iteration/active_record_cursor.rb +14 -8
- data/lib/job-iteration/active_record_enumerator.rb +5 -5
- data/lib/job-iteration/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b07cecd2f672db0710d7e756d1de20db69581ba98bd46109c0023dd8d991ad76
|
4
|
+
data.tar.gz: 598a4a368abc83bd4765aebf61b205592675d76b544806f4458ecec9779005b1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 61cda3903925247899c9051d5de5fac59c9cd36f94172e124e2085174aff5be0677011693018096710a8149582c1589662a1359bb11b0bbdea3c9b7c53916946
|
7
|
+
data.tar.gz: 3773b812a06b4f5700abf4d3c44b65d5aae412545825091c895e294862ca4290aa87b83b7e59a182085fea60d939035f68f2f11ef7ab173c7968cb6cfdff7fd3
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
### Main (unreleased)
|
2
2
|
Nil
|
3
3
|
|
4
|
+
## v1.5.1 (May 29,2024)
|
5
|
+
- [483](https://github.com/Shopify/job-iteration/pull/483) Reverts [#456 Use Arel instead of String for AR Enumerator conditionals](https://github.com/Shopify/job-iteration/pull/456)
|
6
|
+
|
4
7
|
## v1.5.0 (May 29, 2024)
|
5
8
|
### Changes
|
6
9
|
|
data/Gemfile.lock
CHANGED
@@ -18,8 +18,12 @@ module JobIteration
|
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
-
def initialize(relation, columns, position = nil)
|
22
|
-
@columns = columns
|
21
|
+
def initialize(relation, columns = nil, position = nil)
|
22
|
+
@columns = if columns
|
23
|
+
Array(columns)
|
24
|
+
else
|
25
|
+
Array(relation.primary_key).map { |pk| "#{relation.table_name}.#{pk}" }
|
26
|
+
end
|
23
27
|
self.position = Array.wrap(position)
|
24
28
|
raise ArgumentError, "Must specify at least one column" if columns.empty?
|
25
29
|
if relation.joins_values.present? && !@columns.all? { |column| column.to_s.include?(".") }
|
@@ -30,7 +34,7 @@ module JobIteration
|
|
30
34
|
raise ConditionNotSupportedError
|
31
35
|
end
|
32
36
|
|
33
|
-
@base_relation = relation.reorder(
|
37
|
+
@base_relation = relation.reorder(@columns.join(","))
|
34
38
|
@reached_end = false
|
35
39
|
end
|
36
40
|
|
@@ -50,10 +54,12 @@ module JobIteration
|
|
50
54
|
|
51
55
|
def update_from_record(record)
|
52
56
|
self.position = @columns.map do |column|
|
53
|
-
|
57
|
+
method = column.to_s.split(".").last
|
58
|
+
|
59
|
+
if ActiveRecord.version >= Gem::Version.new("7.1.0.alpha") && method == "id"
|
54
60
|
record.id_value
|
55
61
|
else
|
56
|
-
record.send(
|
62
|
+
record.send(method.to_sym)
|
57
63
|
end
|
58
64
|
end
|
59
65
|
end
|
@@ -83,14 +89,14 @@ module JobIteration
|
|
83
89
|
i = @position.size - 1
|
84
90
|
column = @columns[i]
|
85
91
|
conditions = if @columns.size == @position.size
|
86
|
-
column
|
92
|
+
"#{column} > ?"
|
87
93
|
else
|
88
|
-
column
|
94
|
+
"#{column} >= ?"
|
89
95
|
end
|
90
96
|
while i > 0
|
91
97
|
i -= 1
|
92
98
|
column = @columns[i]
|
93
|
-
conditions = column
|
99
|
+
conditions = "#{column} > ? OR (#{column} = ? AND (#{conditions}))"
|
94
100
|
end
|
95
101
|
ret = @position.reduce([conditions]) { |params, value| params << value << value }
|
96
102
|
ret.pop
|
@@ -11,9 +11,9 @@ module JobIteration
|
|
11
11
|
@relation = relation
|
12
12
|
@batch_size = batch_size
|
13
13
|
@columns = if columns
|
14
|
-
Array(columns)
|
14
|
+
Array(columns)
|
15
15
|
else
|
16
|
-
Array(relation.primary_key).map { |pk| relation.
|
16
|
+
Array(relation.primary_key).map { |pk| "#{relation.table_name}.#{pk}" }
|
17
17
|
end
|
18
18
|
@cursor = cursor
|
19
19
|
end
|
@@ -45,7 +45,7 @@ module JobIteration
|
|
45
45
|
|
46
46
|
def cursor_value(record)
|
47
47
|
positions = @columns.map do |column|
|
48
|
-
attribute_name = column.
|
48
|
+
attribute_name = column.to_s.split(".").last
|
49
49
|
column_value(record, attribute_name)
|
50
50
|
end
|
51
51
|
return positions.first if positions.size == 1
|
@@ -58,8 +58,8 @@ module JobIteration
|
|
58
58
|
end
|
59
59
|
|
60
60
|
def column_value(record, attribute)
|
61
|
-
value = record.read_attribute(attribute)
|
62
|
-
case record.class.columns_hash.fetch(attribute
|
61
|
+
value = record.read_attribute(attribute.to_sym)
|
62
|
+
case record.class.columns_hash.fetch(attribute).type
|
63
63
|
when :datetime
|
64
64
|
value.strftime(SQL_DATETIME_WITH_NSEC)
|
65
65
|
else
|