job-iteration 1.1.13 → 1.1.14

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: c1707731e6bf03617bdbaa60bc2ddeb9652f34534a8fe0d69b26e233c790d469
4
- data.tar.gz: a981f1230a7784e4e6673c0d2e4c0642f4a1d3c48baeb3039ca6e41daced9107
3
+ metadata.gz: 0da9051861fb27696febf2d0191b4d2f459ece64b34cf0231398984c0f36ef3d
4
+ data.tar.gz: 5fc84c784cdc1a0558a96891a236ac3cea315068e32a6730d633427ef584204b
5
5
  SHA512:
6
- metadata.gz: db396697d25d4b0450b69d2a58d68e1e247a074f02c9a5887746184789f2aca2569e345ef0d88fb5e142fcaa1c0586169ef91b7bc0ffe2ef35796f544e0cafa1
7
- data.tar.gz: 757b0c074830cbe97d49fd6e84c59ade45c4b5ecdc57b52cf17ea5539e9f2bbffb8ea929804da531c217bf43bbc4f67f726e9d0f1a9a391e32e35837b7edf624
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
- return unless cursor.present?
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module JobIteration
4
- VERSION = "1.1.13"
4
+ VERSION = "1.1.14"
5
5
  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.13
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-20 00:00:00.000000000 Z
11
+ date: 2021-05-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord