job-iteration 1.1.5 → 1.1.6
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 +5 -0
- data/guides/custom-enumerator.md +1 -1
- data/job-iteration.gemspec +1 -0
- data/lib/job-iteration/csv_enumerator.rb +9 -5
- data/lib/job-iteration/iteration.rb +7 -0
- data/lib/job-iteration/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1aa0774feb655e564e01134b940375a88b52eed719e9ff07bfbadb16c4515b7e
|
4
|
+
data.tar.gz: 54a0dd49a916affafc03122db00a2adbc0069268854fae00b751a35db92ebad4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0d1c6b08ef33f876c8fa692ce655f74502758eb6c0e3a98253d9cbb8a29c67906af2a3cbc317dc103a948c514b9eccad9e5938abc2e803f7f3aa25e4a49e9807
|
7
|
+
data.tar.gz: 3693719f3764bf8e158c568a7b63ed8c1b28174016b3d69fc5743711de99f4ad7bb3e80e29f9851e504e50b52ec1783aade73a7a7ee48b03718a9463aa11e98f
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,11 @@
|
|
4
4
|
|
5
5
|
#### Bug fix
|
6
6
|
|
7
|
+
## v1.1.6 (May 22, 2020)
|
8
|
+
|
9
|
+
- [49](https://github.com/Shopify/job-iteration/pull/49) - Log when enumerator has nothing to iterate
|
10
|
+
- [52](https://github.com/Shopify/job-iteration/pull/52) - Fix CSVEnumerator cursor to properly remove already processed rows
|
11
|
+
|
7
12
|
## v1.1.5 (February 27, 2020)
|
8
13
|
|
9
14
|
- [47](https://github.com/Shopify/job-iteration/pull/47) - Optional `sorbet-runtime` support for `JobIteration::Iteration` interface validation
|
data/guides/custom-enumerator.md
CHANGED
data/job-iteration.gemspec
CHANGED
@@ -23,6 +23,7 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.require_paths = %w(lib)
|
24
24
|
|
25
25
|
spec.metadata["changelog_uri"] = "https://github.com/Shopify/job-iteration/blob/master/CHANGELOG.md"
|
26
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
26
27
|
|
27
28
|
spec.add_development_dependency("activerecord")
|
28
29
|
spec.add_dependency("activejob", ">= 5.2")
|
@@ -32,8 +32,8 @@ module JobIteration
|
|
32
32
|
def rows(cursor:)
|
33
33
|
@csv.lazy
|
34
34
|
.each_with_index
|
35
|
-
.drop(cursor
|
36
|
-
.to_enum {
|
35
|
+
.drop(count_of_processed_rows(cursor))
|
36
|
+
.to_enum { count_of_rows_in_file }
|
37
37
|
end
|
38
38
|
|
39
39
|
# Constructs a enumerator on batches of CSV rows
|
@@ -42,13 +42,13 @@ module JobIteration
|
|
42
42
|
@csv.lazy
|
43
43
|
.each_slice(batch_size)
|
44
44
|
.each_with_index
|
45
|
-
.drop(cursor
|
46
|
-
.to_enum { (
|
45
|
+
.drop(count_of_processed_rows(cursor))
|
46
|
+
.to_enum { (count_of_rows_in_file.to_f / batch_size).ceil }
|
47
47
|
end
|
48
48
|
|
49
49
|
private
|
50
50
|
|
51
|
-
def
|
51
|
+
def count_of_rows_in_file
|
52
52
|
# TODO: Remove rescue for NoMethodError when Ruby 2.6 is no longer supported.
|
53
53
|
begin
|
54
54
|
filepath = @csv.path
|
@@ -63,5 +63,9 @@ module JobIteration
|
|
63
63
|
count -= 1 if @csv.headers
|
64
64
|
count
|
65
65
|
end
|
66
|
+
|
67
|
+
def count_of_processed_rows(cursor)
|
68
|
+
cursor.nil? ? 0 : cursor + 1
|
69
|
+
end
|
66
70
|
end
|
67
71
|
end
|
@@ -116,8 +116,10 @@ module JobIteration
|
|
116
116
|
|
117
117
|
def iterate_with_enumerator(enumerator, arguments)
|
118
118
|
arguments = arguments.dup.freeze
|
119
|
+
found_record = false
|
119
120
|
enumerator.each do |object_from_enumerator, index|
|
120
121
|
record_unit_of_work do
|
122
|
+
found_record = true
|
121
123
|
each_iteration(object_from_enumerator, *arguments)
|
122
124
|
self.cursor_position = index
|
123
125
|
end
|
@@ -128,6 +130,11 @@ module JobIteration
|
|
128
130
|
return false
|
129
131
|
end
|
130
132
|
|
133
|
+
logger.info(
|
134
|
+
"[JobIteration::Iteration] Enumerator found nothing to iterate! " \
|
135
|
+
"times_interrupted=#{times_interrupted} cursor_position=#{cursor_position}"
|
136
|
+
) unless found_record
|
137
|
+
|
131
138
|
true
|
132
139
|
end
|
133
140
|
|
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.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shopify
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-05-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -81,6 +81,7 @@ licenses:
|
|
81
81
|
- MIT
|
82
82
|
metadata:
|
83
83
|
changelog_uri: https://github.com/Shopify/job-iteration/blob/master/CHANGELOG.md
|
84
|
+
allowed_push_host: https://rubygems.org
|
84
85
|
post_install_message:
|
85
86
|
rdoc_options: []
|
86
87
|
require_paths:
|