job-iteration 1.1.13 → 1.1.14
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 +8 -0
- data/lib/job-iteration/active_record_batch_enumerator.rb +6 -3
- data/lib/job-iteration/iteration.rb +2 -2
- data/lib/job-iteration/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0da9051861fb27696febf2d0191b4d2f459ece64b34cf0231398984c0f36ef3d
|
4
|
+
data.tar.gz: 5fc84c784cdc1a0558a96891a236ac3cea315068e32a6730d633427ef584204b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f30dbb37ada6149fdd877c4b92fff5cf91e078202408230cbdd19593a341c25f4311b4d12dcdceb539a1553e30e0386930a0b49e4c082a4261a0e788c82125b6
|
7
|
+
data.tar.gz: 88e9846617f7c45959b45328e46b1465b5acb43caf1a5e0b9fa4a5d0848d00d842392ef4383e372f68c7ccb7aa3f0954549a64846cd3e15c712d9a0d7a60d781
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
### Master (unreleased)
|
2
2
|
|
3
|
+
## v1.1.14 (May 28, 2021)
|
4
|
+
|
5
|
+
#### Bug fix
|
6
|
+
- [84](https://github.com/Shopify/job-iteration/pull/84) - Call adjust_total_time before running on_complete callbacks
|
7
|
+
- [94](https://github.com/Shopify/job-iteration/pull/94) - Remove unnecessary break
|
8
|
+
- [95](https://github.com/Shopify/job-iteration/pull/95) - ActiveRecordBatchEnumerator#each should rewind at the end
|
9
|
+
- [97](https://github.com/Shopify/job-iteration/pull/97) - Batch enumerator size returns the number of batches, not records
|
10
|
+
|
3
11
|
## v1.1.13 (May 20, 2021)
|
4
12
|
|
5
13
|
#### New feature
|
@@ -19,6 +19,7 @@ module JobIteration
|
|
19
19
|
@columns.dup << @primary_key
|
20
20
|
end
|
21
21
|
@cursor = Array.wrap(cursor)
|
22
|
+
@initial_cursor = @cursor
|
22
23
|
raise ArgumentError, "Must specify at least one column" if @columns.empty?
|
23
24
|
if relation.joins_values.present? && !@columns.all? { |column| column.to_s.include?(".") }
|
24
25
|
raise ArgumentError, "You need to specify fully-qualified columns if you join a table"
|
@@ -34,13 +35,12 @@ module JobIteration
|
|
34
35
|
def each
|
35
36
|
return to_enum { size } unless block_given?
|
36
37
|
while (relation = next_batch)
|
37
|
-
break if @cursor.nil?
|
38
38
|
yield relation, cursor_value
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
42
|
def size
|
43
|
-
@base_relation.count
|
43
|
+
(@base_relation.count + @batch_size - 1) / @batch_size # ceiling division
|
44
44
|
end
|
45
45
|
|
46
46
|
private
|
@@ -56,7 +56,10 @@ module JobIteration
|
|
56
56
|
end
|
57
57
|
|
58
58
|
cursor = cursor_values.last
|
59
|
-
|
59
|
+
unless cursor.present?
|
60
|
+
@cursor = @initial_cursor
|
61
|
+
return
|
62
|
+
end
|
60
63
|
# The primary key was plucked, but original cursor did not include it, so we should remove it
|
61
64
|
cursor.pop unless @primary_key_index
|
62
65
|
@cursor = Array.wrap(cursor)
|
@@ -162,6 +162,8 @@ module JobIteration
|
|
162
162
|
"times_interrupted=#{times_interrupted} cursor_position=#{cursor_position}"
|
163
163
|
) unless found_record
|
164
164
|
|
165
|
+
adjust_total_time
|
166
|
+
|
165
167
|
true
|
166
168
|
end
|
167
169
|
|
@@ -249,8 +251,6 @@ module JobIteration
|
|
249
251
|
end
|
250
252
|
|
251
253
|
def output_interrupt_summary
|
252
|
-
adjust_total_time
|
253
|
-
|
254
254
|
message = "[JobIteration::Iteration] Completed iterating. times_interrupted=%d total_time=%.3f"
|
255
255
|
logger.info(Kernel.format(message, times_interrupted, total_time))
|
256
256
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: job-iteration
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shopify
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-05-
|
11
|
+
date: 2021-05-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|