job-iteration 1.6.0 → 1.7.0
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/.github/workflows/ci.yml +9 -1
- data/CHANGELOG.md +12 -1
- data/Gemfile.lock +1 -1
- data/lib/job-iteration/active_record_batch_enumerator.rb +6 -2
- data/lib/job-iteration/active_record_enumerator.rb +3 -1
- data/lib/job-iteration/enumerator_builder.rb +5 -0
- data/lib/job-iteration/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0c3d42266a1de05ed85c35d99e76b55a131144054db3e3b83026aa3e180488c6
|
4
|
+
data.tar.gz: c272d3a7e0316cbb0a9b34326f8b1cdff5cb43c2ff58828dea1767a7f47eecb9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 500cefbc1ab8e7f02a4679b13f8c1401662e63021d20b2b4b5209d979f70c208d5b2a91ed5765d5dc5739666772fbe86e6f1a3e658bd9b1dad03f4b42d97b270
|
7
|
+
data.tar.gz: 37e100ba000a3ab67a07e78937ac12c58822a13e8f5641e6a3312a49a51733da3a1d4d3c8bf1a1f1928fc45c3aa026caf003fb97565a412e4c371b389513c7bb
|
data/.github/workflows/ci.yml
CHANGED
@@ -15,29 +15,37 @@ jobs:
|
|
15
15
|
strategy:
|
16
16
|
matrix:
|
17
17
|
ruby: ["2.6", "2.7", "3.0", "3.1", "3.2", "3.3"]
|
18
|
-
rails: ["5.2", "6.0", "6.1", "7.0", "7.1", "edge"]
|
18
|
+
rails: ["5.2", "6.0", "6.1", "7.0", "7.1", "7.2", "edge"]
|
19
19
|
gemfile: [rails_gems]
|
20
20
|
exclude:
|
21
21
|
- ruby: "2.6"
|
22
22
|
rails: "7.0"
|
23
23
|
- ruby: "2.6"
|
24
24
|
rails: "7.1"
|
25
|
+
- ruby: "2.6"
|
26
|
+
rails: "7.2"
|
25
27
|
- ruby: "2.6"
|
26
28
|
rails: "edge"
|
27
29
|
- ruby: "2.7"
|
28
30
|
rails: "7.1"
|
31
|
+
- ruby: "2.7"
|
32
|
+
rails: "7.2"
|
29
33
|
- ruby: "2.7"
|
30
34
|
rails: "edge"
|
31
35
|
- ruby: "3.0"
|
32
36
|
rails: "5.2"
|
33
37
|
- ruby: "3.0"
|
34
38
|
rails: "7.1"
|
39
|
+
- ruby: "3.0"
|
40
|
+
rails: "7.2"
|
35
41
|
- ruby: "3.0"
|
36
42
|
rails: "edge"
|
37
43
|
- ruby: "3.1"
|
38
44
|
rails: "5.2"
|
39
45
|
- ruby: "3.1"
|
40
46
|
rails: "6.0"
|
47
|
+
- ruby: "3.1"
|
48
|
+
rails: "edge"
|
41
49
|
- ruby: "3.2"
|
42
50
|
rails: "5.2"
|
43
51
|
- ruby: "3.2"
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,13 @@
|
|
2
2
|
|
3
3
|
Nil
|
4
4
|
|
5
|
+
## v1.7.0 (Oct 11, 2024)
|
6
|
+
|
7
|
+
### Features
|
8
|
+
|
9
|
+
- [509](https://github.com/Shopify/job-iteration/pull/509) - Added CSV batching functionality to `EnumeratorBuilder` with `build_csv_enumerator_on_batches` method and `csv_on_batches` alias.
|
10
|
+
- [512](https://github.com/Shopify/job-iteration/pull/512) - Added support for custom timezones on `ActiveRecordEnumerator` and `ActiveRecordBatchEnumerator`. This allows for using cursors with datetime columns where `ActiveRecord.default_timezone` is set to `:local` and Active Record is not using the same timezone as the database.
|
11
|
+
|
5
12
|
## v1.6.0 (Sep 24, 2024)
|
6
13
|
|
7
14
|
### Features
|
@@ -10,9 +17,13 @@ Nil
|
|
10
17
|
- [505](https://github.com/Shopify/job-iteration/pull/505) - Add interruption adapter for [Solid Queue](https://github.com/rails/solid_queue).
|
11
18
|
|
12
19
|
## v1.5.1 (May 29,2024)
|
20
|
+
|
21
|
+
### Bug fixes
|
22
|
+
|
13
23
|
- [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)
|
14
24
|
|
15
25
|
## v1.5.0 (May 29, 2024)
|
26
|
+
|
16
27
|
### Changes
|
17
28
|
|
18
29
|
- [437](https://github.com/Shopify/job-iteration/pull/437) - Use minimum between per-class `job_iteration_max_job_runtime` and `JobIteration.max_job_runtime`, instead of enforcing only setting decreasing values.
|
@@ -29,7 +40,7 @@ when generating position for cursor based on `:id` column (Rails 7.1 and above,
|
|
29
40
|
primary models are now supported). This ensures we grab the value of the id column, rather than a
|
30
41
|
potentially composite primary key value.
|
31
42
|
- [456](https://github.com/Shopify/job-iteration/pull/431) - Use Arel to generate SQL that's type compatible for the
|
32
|
-
cursor pagination conditionals in ActiveRecord cursor. Previously, the cursor would coerce numeric ids to a string value
|
43
|
+
cursor pagination conditionals in ActiveRecord cursor. Previously, the cursor would coerce numeric ids to a string value
|
33
44
|
(e.g.: `... AND id > '1'`)
|
34
45
|
|
35
46
|
## v1.4.1 (Sep 5, 2023)
|
data/Gemfile.lock
CHANGED
@@ -8,8 +8,9 @@ module JobIteration
|
|
8
8
|
|
9
9
|
SQL_DATETIME_WITH_NSEC = "%Y-%m-%d %H:%M:%S.%N"
|
10
10
|
|
11
|
-
def initialize(relation, columns: nil, batch_size: 100, cursor: nil)
|
11
|
+
def initialize(relation, columns: nil, batch_size: 100, timezone: nil, cursor: nil)
|
12
12
|
@batch_size = batch_size
|
13
|
+
@timezone = timezone
|
13
14
|
@primary_key = "#{relation.table_name}.#{relation.primary_key}"
|
14
15
|
@columns = Array(columns&.map(&:to_s) || @primary_key)
|
15
16
|
@primary_key_index = @columns.index(@primary_key) || @columns.index(relation.primary_key)
|
@@ -114,7 +115,10 @@ module JobIteration
|
|
114
115
|
end
|
115
116
|
|
116
117
|
def column_value(value)
|
117
|
-
value.is_a?(Time)
|
118
|
+
return value unless value.is_a?(Time)
|
119
|
+
|
120
|
+
value = value.in_time_zone(@timezone) unless @timezone.nil?
|
121
|
+
value.strftime(SQL_DATETIME_WITH_NSEC)
|
118
122
|
end
|
119
123
|
end
|
120
124
|
end
|
@@ -7,9 +7,10 @@ module JobIteration
|
|
7
7
|
class ActiveRecordEnumerator
|
8
8
|
SQL_DATETIME_WITH_NSEC = "%Y-%m-%d %H:%M:%S.%N"
|
9
9
|
|
10
|
-
def initialize(relation, columns: nil, batch_size: 100, cursor: nil)
|
10
|
+
def initialize(relation, columns: nil, batch_size: 100, timezone: nil, cursor: nil)
|
11
11
|
@relation = relation
|
12
12
|
@batch_size = batch_size
|
13
|
+
@timezone = timezone
|
13
14
|
@columns = if columns
|
14
15
|
Array(columns)
|
15
16
|
else
|
@@ -61,6 +62,7 @@ module JobIteration
|
|
61
62
|
value = record.read_attribute(attribute.to_sym)
|
62
63
|
case record.class.columns_hash.fetch(attribute).type
|
63
64
|
when :datetime
|
65
|
+
value = value.in_time_zone(@timezone) unless @timezone.nil?
|
64
66
|
value.strftime(SQL_DATETIME_WITH_NSEC)
|
65
67
|
else
|
66
68
|
value
|
@@ -144,6 +144,10 @@ module JobIteration
|
|
144
144
|
CsvEnumerator.new(enumerable).rows(cursor: cursor)
|
145
145
|
end
|
146
146
|
|
147
|
+
def build_csv_enumerator_on_batches(enumerable, cursor:, batch_size: 100)
|
148
|
+
CsvEnumerator.new(enumerable).batches(cursor: cursor, batch_size: batch_size)
|
149
|
+
end
|
150
|
+
|
147
151
|
# Builds Enumerator for nested iteration.
|
148
152
|
#
|
149
153
|
# @param enums [Array<Proc>] an Array of Procs, each should return an Enumerator.
|
@@ -186,6 +190,7 @@ module JobIteration
|
|
186
190
|
alias_method :active_record_on_batch_relations, :build_active_record_enumerator_on_batch_relations
|
187
191
|
alias_method :throttle, :build_throttle_enumerator
|
188
192
|
alias_method :csv, :build_csv_enumerator
|
193
|
+
alias_method :csv_on_batches, :build_csv_enumerator_on_batches
|
189
194
|
alias_method :nested, :build_nested_enumerator
|
190
195
|
|
191
196
|
private
|
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.
|
4
|
+
version: 1.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shopify
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-10-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activejob
|
@@ -95,7 +95,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
97
|
requirements: []
|
98
|
-
rubygems_version: 3.5.
|
98
|
+
rubygems_version: 3.5.21
|
99
99
|
signing_key:
|
100
100
|
specification_version: 4
|
101
101
|
summary: Makes your background jobs interruptible and resumable.
|