job-iteration 1.1.9 → 1.1.10

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: 1a4821d55797f7597b3c916d6fbca2195c054bd3aab0ffcc40c9ce21ae0b1ec4
4
- data.tar.gz: e71ce0fb7ec744b502f018ccfc7ea5e819bfe06f9fb2ca5a32c70cc1b875abc7
3
+ metadata.gz: 7868f8da1aee096abee4d4a1848c2242d0a7ac9bb1b456ad8385cfe6421a902e
4
+ data.tar.gz: fd82a4cdfcbff16220363e1c53aa064b0cd5e599e17290aa968fdb01d8fe4002
5
5
  SHA512:
6
- metadata.gz: 943795fabf60cff76fa7b8678f1f5d5a83bd98340194e142092dc891ff1abe991c0410572cebd09155c6c220ff96aa5530fb27e1b4fe119c6bbbf22fe12670ef
7
- data.tar.gz: 11ea6f0165aa31350c6486236a33d66c94316a08f52905aeaab049388b433c229ccf52e69ae3e43eb8bca9a5c56dc4aae46803aae4add9d2a052d5d49af14d8d
6
+ metadata.gz: 42a601bb25a38571c97d108a8847317892a5289e2d3f8d818b68c99a49fc6d142dffcdd9191350261a89db65bf24aa3b0691057238f2416e2a0140bf16c47485
7
+ data.tar.gz: 364868992c7fe4602f31d453891f4597d73d0b7b76482510d7ae9d3d3de7baf951465c5df7fcf9923592abb05b3584a9206f104bd610ab52dbbf3625c03be3f6
@@ -0,0 +1,47 @@
1
+ name: Ruby
2
+
3
+ on: [push]
4
+
5
+ jobs:
6
+ build:
7
+ runs-on: ubuntu-latest
8
+ name: Ruby ${{ matrix.ruby }}
9
+ services:
10
+ redis:
11
+ image: redis
12
+ ports:
13
+ - 6379:6379
14
+ strategy:
15
+ matrix:
16
+ ruby: [2.5, 2.6, 2.7, 3.0]
17
+ gemfile: [rails_5_2, rails_6_0, rails_edge]
18
+ exclude:
19
+ - ruby: 2.5
20
+ gemfile: rails_edge
21
+ - ruby: 2.6
22
+ gemfile: rails_edge
23
+ - ruby: 3.0
24
+ gemfile: rails_5_2
25
+ env:
26
+ BUNDLE_GEMFILE: gemfiles/${{ matrix.gemfile }}.gemfile
27
+ steps:
28
+ - name: Check out code
29
+ uses: actions/checkout@v2
30
+ - name: Set up Ruby ${{ matrix.ruby }}
31
+ uses: ruby/setup-ruby@v1
32
+ with:
33
+ ruby-version: ${{ matrix.ruby }}
34
+ bundler-cache: true
35
+ - name: Start MySQL and create DB
36
+ run: |
37
+ sudo systemctl start mysql.service
38
+ mysql -uroot -h localhost -proot -e "CREATE DATABASE job_iteration_test;"
39
+ - name: Rubocop
40
+ run: bundle exec rubocop
41
+ - name: Ruby tests
42
+ run: bundle exec rake test
43
+ env:
44
+ REDIS_HOST: localhost
45
+ REDIS_PORT: ${{ job.services.redis.ports[6379] }}
46
+ - name: Documentation correctly written
47
+ run: bundle exec yardoc --no-output --no-save --no-stats --fail-on-warning
data/.rubocop.yml CHANGED
@@ -1,5 +1,5 @@
1
- inherit_from:
2
- - http://shopify.github.io/ruby-style-guide/rubocop.yml
1
+ inherit_gem:
2
+ rubocop-shopify: rubocop.yml
3
3
 
4
4
  AllCops:
5
5
  TargetRubyVersion: 2.4.4
data/CHANGELOG.md CHANGED
@@ -4,6 +4,10 @@
4
4
 
5
5
  #### Bug fix
6
6
 
7
+ ## v1.1.10 (March 30, 2021)
8
+
9
+ - [69](https://github.com/Shopify/job-iteration/pull/69) Fix memory leak in ActiveRecordCursor
10
+
7
11
  ## v1.1.9 (January 6, 2021)
8
12
 
9
13
  - [61](https://github.com/Shopify/job-iteration/pull/61) Call `super` in `method_added`
data/Gemfile CHANGED
@@ -8,21 +8,21 @@ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
8
8
  gemspec
9
9
 
10
10
  # for integration testing
11
- gem 'sidekiq'
12
- gem 'resque'
11
+ gem "sidekiq"
12
+ gem "resque"
13
13
 
14
- gem 'mysql2', '~> 0.5'
15
- gem 'globalid'
16
- gem 'i18n'
17
- gem 'redis'
18
- gem 'database_cleaner'
14
+ gem "mysql2", "~> 0.5"
15
+ gem "globalid"
16
+ gem "i18n"
17
+ gem "redis"
18
+ gem "database_cleaner"
19
19
 
20
- gem 'pry'
21
- gem 'mocha'
20
+ gem "pry"
21
+ gem "mocha"
22
22
 
23
- gem 'rubocop', '~> 0.77.0'
24
- gem 'yard'
25
- gem 'rake'
23
+ gem "rubocop-shopify", require: false
24
+ gem "yard"
25
+ gem "rake"
26
26
 
27
27
  # for unit testing optional sorbet support
28
- gem 'sorbet-runtime'
28
+ gem "sorbet-runtime"
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- eval_gemfile '../Gemfile'
3
+ eval_gemfile "../Gemfile"
4
4
 
5
- gem 'activejob', '~> 5.2.0'
6
- gem 'activerecord', '~> 5.2.0'
5
+ gem "activejob", "~> 5.2.0"
6
+ gem "activerecord", "~> 5.2.0"
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- eval_gemfile '../Gemfile'
3
+ eval_gemfile "../Gemfile"
4
4
 
5
- gem 'activejob', '~> 6.0.0'
6
- gem 'activerecord', '~> 6.0.0'
5
+ gem "activejob", "~> 6.0.0"
6
+ gem "activerecord", "~> 6.0.0"
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- eval_gemfile '../Gemfile'
3
+ eval_gemfile "../Gemfile"
4
4
 
5
- gem 'activejob', github: 'rails/rails'
6
- gem 'activerecord', github: 'rails/rails'
5
+ gem "activejob", github: "rails/rails", branch: "main"
6
+ gem "activerecord", github: "rails/rails", branch: "main"
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.authors = %w(Shopify)
11
11
  spec.email = ["ops-accounts+shipit@shopify.com"]
12
12
 
13
- spec.summary = 'Makes your background jobs interruptible and resumable.'
13
+ spec.summary = "Makes your background jobs interruptible and resumable."
14
14
  spec.description = spec.summary
15
15
  spec.homepage = "https://github.com/shopify/job-iteration"
16
16
  spec.license = "MIT"
data/lib/job-iteration.rb CHANGED
@@ -54,11 +54,11 @@ module JobIteration
54
54
  def load_integration(integration)
55
55
  unless INTEGRATIONS.include?(integration)
56
56
  raise IntegrationLoadError,
57
- "#{integration} integration is not supported. Available integrations: #{INTEGRATIONS.join(', ')}"
57
+ "#{integration} integration is not supported. Available integrations: #{INTEGRATIONS.join(", ")}"
58
58
  end
59
59
 
60
60
  require_relative "./job-iteration/integrations/#{integration}"
61
61
  end
62
62
  end
63
63
 
64
- JobIteration.load_integrations unless ENV['ITERATION_DISABLE_AUTOCONFIGURE']
64
+ JobIteration.load_integrations unless ENV["ITERATION_DISABLE_AUTOCONFIGURE"]
@@ -23,7 +23,7 @@ module JobIteration
23
23
  @columns = Array.wrap(columns)
24
24
  self.position = Array.wrap(position)
25
25
  raise ArgumentError, "Must specify at least one column" if columns.empty?
26
- if relation.joins_values.present? && !@columns.all? { |column| column.to_s.include?('.') }
26
+ if relation.joins_values.present? && !@columns.all? { |column| column.to_s.include?(".") }
27
27
  raise ArgumentError, "You need to specify fully-qualified columns if you join a table"
28
28
  end
29
29
 
@@ -31,7 +31,7 @@ module JobIteration
31
31
  raise ConditionNotSupportedError
32
32
  end
33
33
 
34
- @base_relation = relation.reorder(@columns.join(','))
34
+ @base_relation = relation.reorder(@columns.join(","))
35
35
  @reached_end = false
36
36
  end
37
37
 
@@ -50,7 +50,7 @@ module JobIteration
50
50
 
51
51
  def update_from_record(record)
52
52
  self.position = @columns.map do |column|
53
- method = column.to_s.split('.').last
53
+ method = column.to_s.split(".").last
54
54
  record.send(method.to_sym)
55
55
  end
56
56
  end
@@ -64,7 +64,9 @@ module JobIteration
64
64
  relation = relation.where(*conditions)
65
65
  end
66
66
 
67
- records = relation.to_a
67
+ records = relation.uncached do
68
+ relation.to_a
69
+ end
68
70
 
69
71
  update_from_record(records.last) unless records.empty?
70
72
  @reached_end = records.size < batch_size
@@ -40,7 +40,7 @@ module JobIteration
40
40
 
41
41
  def cursor_value(record)
42
42
  positions = @columns.map do |column|
43
- attribute_name = column.to_s.split('.').last
43
+ attribute_name = column.to_s.split(".").last
44
44
  column_value(record, attribute_name)
45
45
  end
46
46
  return positions.first if positions.size == 1
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'resque'
3
+ require "resque"
4
4
 
5
5
  module JobIteration
6
6
  module Integrations
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'sidekiq'
3
+ require "sidekiq"
4
4
 
5
5
  module JobIteration
6
6
  module Integrations # @private
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'active_support/all'
3
+ require "active_support/all"
4
4
 
5
5
  module JobIteration
6
6
  module Iteration
@@ -54,17 +54,17 @@ module JobIteration
54
54
 
55
55
  def serialize # @private
56
56
  super.merge(
57
- 'cursor_position' => cursor_position,
58
- 'times_interrupted' => times_interrupted,
59
- 'total_time' => total_time,
57
+ "cursor_position" => cursor_position,
58
+ "times_interrupted" => times_interrupted,
59
+ "total_time" => total_time,
60
60
  )
61
61
  end
62
62
 
63
63
  def deserialize(job_data) # @private
64
64
  super
65
- self.cursor_position = job_data['cursor_position']
66
- self.times_interrupted = job_data['times_interrupted'] || 0
67
- self.total_time = job_data['total_time'] || 0
65
+ self.cursor_position = job_data["cursor_position"]
66
+ self.times_interrupted = job_data["times_interrupted"] || 0
67
+ self.total_time = job_data["total_time"] || 0
68
68
  end
69
69
 
70
70
  def perform(*params) # @private
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module JobIteration
4
- VERSION = "1.1.9"
4
+ VERSION = "1.1.10"
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.9
4
+ version: 1.1.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shopify
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-01-06 00:00:00.000000000 Z
11
+ date: 2021-03-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -45,9 +45,9 @@ executables: []
45
45
  extensions: []
46
46
  extra_rdoc_files: []
47
47
  files:
48
+ - ".github/workflows/ruby.yml"
48
49
  - ".gitignore"
49
50
  - ".rubocop.yml"
50
- - ".travis.yml"
51
51
  - ".yardopts"
52
52
  - CHANGELOG.md
53
53
  - CODE_OF_CONDUCT.md
data/.travis.yml DELETED
@@ -1,19 +0,0 @@
1
- services:
2
- - mysql
3
- - redis-server
4
- language: ruby
5
- rvm:
6
- - 2.5
7
- - 2.6
8
- - 2.7
9
- before_install:
10
- - mysql -e 'CREATE DATABASE job_iteration_test;'
11
- script:
12
- - bundle exec rake test
13
- - bundle exec rubocop
14
- - bundle exec yardoc --no-output --no-save --no-stats --fail-on-warning
15
-
16
- gemfile:
17
- - 'gemfiles/rails_5_2.gemfile'
18
- - 'gemfiles/rails_6_0.gemfile'
19
- - 'gemfiles/rails_edge.gemfile'