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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cdace86b05a5a1d98777e2310d85d75679073ca63b5e52b0e83bd000891198cf
4
- data.tar.gz: 4ed5b475931e24bf56d2b8b126bd9354064c438d0ea16f67c10276fb92ccd97b
3
+ metadata.gz: b07cecd2f672db0710d7e756d1de20db69581ba98bd46109c0023dd8d991ad76
4
+ data.tar.gz: 598a4a368abc83bd4765aebf61b205592675d76b544806f4458ecec9779005b1
5
5
  SHA512:
6
- metadata.gz: cf9d7a54a8881146a4a0a1750e99dddf8d32c9db3339411fc61c8477a89f5766e9bb99f493257e4484d56e18ef443cb6a2a0300958342774d2e7ebd2b3e23c32
7
- data.tar.gz: 966c39a5e89ae26343e07000111ba582724b85b4bf9b7a17f790a10b679e297dca94105d3fb42830f987498fb8982037c80cf3e8130b8bede845f9c7532ade41
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
@@ -7,7 +7,7 @@ GIT
7
7
  PATH
8
8
  remote: .
9
9
  specs:
10
- job-iteration (1.5.0)
10
+ job-iteration (1.5.1)
11
11
  activejob (>= 5.2)
12
12
 
13
13
  GEM
@@ -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(*@columns)
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
- if ActiveRecord.version >= Gem::Version.new("7.1.0.alpha") && column.name == "id"
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(column.name)
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.gt(@position[i])
92
+ "#{column} > ?"
87
93
  else
88
- column.gteq(@position[i])
94
+ "#{column} >= ?"
89
95
  end
90
96
  while i > 0
91
97
  i -= 1
92
98
  column = @columns[i]
93
- conditions = column.gt(@position[i]).or(column.eq(@position[i]).and(conditions))
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).map { |col| relation.arel_table[col.to_sym] }
14
+ Array(columns)
15
15
  else
16
- Array(relation.primary_key).map { |pk| relation.arel_table[pk.to_sym] }
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.name.to_sym
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.to_s).type
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module JobIteration
4
- VERSION = "1.5.0"
4
+ VERSION = "1.5.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: job-iteration
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0
4
+ version: 1.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shopify