sequel-batches 1.1.0 → 2.0.2

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: 2ba86551c2e6fa28e3c012fec381ca293267b3c04629f8295114724a2c7ff99a
4
- data.tar.gz: c36a543672f8d6869e4189ad808ac15c275d0342cc41ec3a258a0299e4225829
3
+ metadata.gz: 3cd6e15b3473080a3ccc2db4959cddb601624fc0bde9bda3bfad153d9e60194b
4
+ data.tar.gz: 840ea07efcc58c518a2022f21e4423fc1e2887b2a552c05d5905077ae02daa8a
5
5
  SHA512:
6
- metadata.gz: 655a16e69b97c23fe80c92beef06e5cc80fa242b161955ef3702193385528b67b8575a14c5b75ed0e7cc4af559e1a04e0e0141e8ab4ef60c5cfc350ac5afda9c
7
- data.tar.gz: c36d801caaf7cefc37520c4db12ce9d47ff62c20eb2c9c8c2c9813775829bd5acbaa0bc8f1d6953b5fc1c6dfbcea34650eec29ca37f8c15731872bd1915f193a
6
+ metadata.gz: a1ae993708db8f425d9901047fb868498f0b1e0957e2fc56578ec23f388e095fd2ba509a3a09c7b9d485c9b7f7e1bf390144bc2e74c09bf585c7b4b708376b24
7
+ data.tar.gz: 5d19d482faf0959d6a873dd17dc62595c7d5c972d1d35d169ece1c53f880d5ba1e116b6db5d27e04e3731c2f74da989ac361df215fe9d2daa061a2c6b9e43f69
@@ -29,7 +29,7 @@ jobs:
29
29
  strategy:
30
30
  fail-fast: false
31
31
  matrix:
32
- ruby: [2.6, 2.7, "3.0", jruby-9.3.1.0, ruby-head, jruby-head]
32
+ ruby: ["2.7", "3.0", "3.1"]
33
33
 
34
34
  name: ${{ matrix.ruby }}
35
35
 
@@ -44,7 +44,6 @@ jobs:
44
44
  - run: bundle exec rake bundle:audit
45
45
  - run: bundle exec rake lint
46
46
  - run: bundle exec rspec
47
- continue-on-error: ${{ matrix.ruby == 'jruby-head' || matrix.ruby == 'ruby-head' }}
48
47
 
49
48
  - uses: coverallsapp/github-action@v1.1.2
50
49
  with:
data/.gitignore CHANGED
@@ -11,7 +11,6 @@
11
11
  .rspec_status
12
12
 
13
13
  *.gem
14
- *.lock
15
14
  *.log
16
15
  .coveralls.yml
17
16
  .ruby-version
data/.rubocop.yml CHANGED
@@ -3,7 +3,7 @@ inherit_gem:
3
3
 
4
4
  AllCops:
5
5
  DisplayCopNames: true
6
- TargetRubyVersion: 2.6
6
+ TargetRubyVersion: 2.7
7
7
  Include:
8
8
  - lib/**/*.rb
9
9
  - spec/**/*.rb
data/Gemfile CHANGED
@@ -4,13 +4,3 @@ source "https://rubygems.org"
4
4
 
5
5
  # Specify your gem's dependencies in sequel-batches.gemspec
6
6
  gemspec
7
-
8
- # MRI/Rubinius Adapter Dependencies
9
- platforms :ruby do
10
- gem "pg"
11
- end
12
-
13
- # JRuby Adapter Dependencies
14
- platforms :jruby do
15
- gem "jdbc-postgres"
16
- end
data/Gemfile.lock ADDED
@@ -0,0 +1,113 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ sequel-batches (2.0.2)
5
+ sequel
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ activesupport (7.0.3.1)
11
+ concurrent-ruby (~> 1.0, >= 1.0.2)
12
+ i18n (>= 1.6, < 2)
13
+ minitest (>= 5.1)
14
+ tzinfo (~> 2.0)
15
+ ast (2.4.2)
16
+ bundler-audit (0.9.1)
17
+ bundler (>= 1.2.0, < 3)
18
+ thor (~> 1.0)
19
+ coderay (1.1.3)
20
+ concurrent-ruby (1.1.10)
21
+ diff-lcs (1.5.0)
22
+ docile (1.4.0)
23
+ i18n (1.12.0)
24
+ concurrent-ruby (~> 1.0)
25
+ method_source (1.0.0)
26
+ minitest (5.16.2)
27
+ parallel (1.22.1)
28
+ parser (3.1.2.1)
29
+ ast (~> 2.4.1)
30
+ pg (1.4.2)
31
+ pry (0.14.1)
32
+ coderay (~> 1.1)
33
+ method_source (~> 1.0)
34
+ rack (2.2.4)
35
+ rainbow (3.1.1)
36
+ rake (13.0.6)
37
+ regexp_parser (2.5.0)
38
+ rexml (3.2.5)
39
+ rspec (3.11.0)
40
+ rspec-core (~> 3.11.0)
41
+ rspec-expectations (~> 3.11.0)
42
+ rspec-mocks (~> 3.11.0)
43
+ rspec-core (3.11.0)
44
+ rspec-support (~> 3.11.0)
45
+ rspec-expectations (3.11.0)
46
+ diff-lcs (>= 1.2.0, < 2.0)
47
+ rspec-support (~> 3.11.0)
48
+ rspec-mocks (3.11.1)
49
+ diff-lcs (>= 1.2.0, < 2.0)
50
+ rspec-support (~> 3.11.0)
51
+ rspec-support (3.11.0)
52
+ rubocop (1.30.1)
53
+ parallel (~> 1.10)
54
+ parser (>= 3.1.0.0)
55
+ rainbow (>= 2.2.2, < 4.0)
56
+ regexp_parser (>= 1.8, < 3.0)
57
+ rexml (>= 3.2.5, < 4.0)
58
+ rubocop-ast (>= 1.18.0, < 2.0)
59
+ ruby-progressbar (~> 1.7)
60
+ unicode-display_width (>= 1.4.0, < 3.0)
61
+ rubocop-ast (1.21.0)
62
+ parser (>= 3.1.1.0)
63
+ rubocop-config-umbrellio (1.30.0.65)
64
+ rubocop (~> 1.30.0)
65
+ rubocop-performance (~> 1.14.0)
66
+ rubocop-rails (~> 2.14.2)
67
+ rubocop-rake (~> 0.6.0)
68
+ rubocop-rspec (~> 2.11.1)
69
+ rubocop-sequel (~> 0.3.3)
70
+ rubocop-performance (1.14.3)
71
+ rubocop (>= 1.7.0, < 2.0)
72
+ rubocop-ast (>= 0.4.0)
73
+ rubocop-rails (2.14.2)
74
+ activesupport (>= 4.2.0)
75
+ rack (>= 1.1)
76
+ rubocop (>= 1.7.0, < 2.0)
77
+ rubocop-rake (0.6.0)
78
+ rubocop (~> 1.0)
79
+ rubocop-rspec (2.11.1)
80
+ rubocop (~> 1.19)
81
+ rubocop-sequel (0.3.4)
82
+ rubocop (~> 1.0)
83
+ ruby-progressbar (1.11.0)
84
+ sequel (5.59.0)
85
+ simplecov (0.21.2)
86
+ docile (~> 1.1)
87
+ simplecov-html (~> 0.11)
88
+ simplecov_json_formatter (~> 0.1)
89
+ simplecov-html (0.12.3)
90
+ simplecov-lcov (0.8.0)
91
+ simplecov_json_formatter (0.1.4)
92
+ thor (1.2.1)
93
+ tzinfo (2.0.5)
94
+ concurrent-ruby (~> 1.0)
95
+ unicode-display_width (2.2.0)
96
+
97
+ PLATFORMS
98
+ ruby
99
+
100
+ DEPENDENCIES
101
+ bundler
102
+ bundler-audit
103
+ pg
104
+ pry
105
+ rake
106
+ rspec
107
+ rubocop-config-umbrellio
108
+ sequel-batches!
109
+ simplecov
110
+ simplecov-lcov
111
+
112
+ BUNDLED WITH
113
+ 2.3.19
data/README.md CHANGED
@@ -12,14 +12,6 @@ Add this line to your application's Gemfile:
12
12
  gem 'sequel-batches'
13
13
  ```
14
14
 
15
- And then execute:
16
-
17
- $ bundle
18
-
19
- Or install it yourself as:
20
-
21
- $ gem install sequel-batches
22
-
23
15
  ## Usage
24
16
 
25
17
  In order to use the feature you should enable the extension:
@@ -57,21 +49,26 @@ end
57
49
  You can set the following options:
58
50
 
59
51
  ### pk
52
+
60
53
  Overrides primary key of your dataset. This option is required in case your table doesn't have a real PK, otherwise you will get `Sequel::Extensions::Batches::MissingPKError`.
61
54
 
62
55
  Note that you have to provide columns that don't contain NULL values, otherwise this may not work as intended. You will receive `Sequel::Extensions::Batches::NullPKError` in case batch processing detects a NULL value on it's way, but it's not guaranteed since it doesn't check all the rows for performance reasons.
63
56
 
64
57
  ### of
58
+
65
59
  Sets chunk size (1000 by default).
66
60
 
67
61
  ### start
62
+
68
63
  A hash `{ [column]: <start_value> }` that represents frame start for batch processing. Note that you will get `Sequel::Extensions::Batches::InvalidPKError` in case you provide a hash with wrong keys (ordering matters as well).
69
64
 
70
65
  ### finish
66
+
71
67
  Same as `start` but represents the frame end.
72
68
 
73
69
  ### order
74
- Specifies the primary key order (can be :asc or :desc). Defaults to :asc.
70
+
71
+ Specifies the primary key order (can be `:asc` or `:desc`). Defaults to `:asc`.
75
72
 
76
73
  ## Contributing
77
74
 
@@ -6,7 +6,7 @@ module Sequel::Extensions::Batches
6
6
  attr_writer :pk
7
7
 
8
8
  def initialize(ds:, **options)
9
- self.ds = ds
9
+ self.ds = ds.unordered
10
10
  self.pk = options.delete(:pk)
11
11
  self.of = options.delete(:of) || 1000
12
12
  self.start = options.delete(:start)
@@ -31,8 +31,8 @@ module Sequel::Extensions::Batches
31
31
  base_ds
32
32
  end
33
33
 
34
- working_ds_pk = working_ds.select(*qualified_pk).order(order_by).limit(of)
35
- current_instance = db.from(working_ds_pk).select(*pk).order(order_by).last or break
34
+ working_ds_pk = working_ds.select(*qualified_pk).order(*order_by(qualified: true)).limit(of)
35
+ current_instance = db.from(working_ds_pk).select(*pk).order(*order_by).last or break
36
36
  working_ds = working_ds.where(generate_conditions(current_instance.to_h, sign: sign_to_inclusive))
37
37
 
38
38
  yield working_ds
@@ -70,14 +70,18 @@ module Sequel::Extensions::Batches
70
70
  end
71
71
 
72
72
  def order_by(qualified: false)
73
- columns = qualified ? qualified_pk : pk
74
- asc_order? ? Sequel.asc(columns) : Sequel.desc(columns)
73
+ columns = qualified ? qualified_pk : unqualified_pk
74
+ asc_order? ? columns.map(&:asc) : columns.map(&:desc)
75
75
  end
76
76
 
77
77
  def qualified_pk
78
78
  @qualified_pk ||= pk.map { |x| Sequel[ds.first_source][x] }
79
79
  end
80
80
 
81
+ def unqualified_pk
82
+ @unqualified_pk ||= pk.map { |x| x.is_a?(Symbol) ? Sequel[x] : x }
83
+ end
84
+
81
85
  def check_pk(input_pk)
82
86
  raise InvalidPKError if input_pk.keys != pk
83
87
  input_pk
@@ -90,11 +94,11 @@ module Sequel::Extensions::Batches
90
94
  end
91
95
 
92
96
  def setup_base_ds
93
- base_ds = ds.order(order_by(qualified: true))
97
+ base_ds = ds.order(*order_by(qualified: true))
94
98
  base_ds = base_ds.where(generate_conditions(check_pk(start), sign: sign_from_inclusive)) if start
95
99
  base_ds = base_ds.where(generate_conditions(check_pk(finish), sign: sign_to_inclusive)) if finish
96
100
 
97
- pk_ds = db.from(base_ds.select(*qualified_pk)).select(*pk).order(order_by)
101
+ pk_ds = db.from(base_ds.select(*qualified_pk)).select(*pk).order(*order_by)
98
102
  actual_start = pk_ds.first
99
103
  actual_finish = pk_ds.last
100
104
 
@@ -5,10 +5,10 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "sequel-batches"
8
- spec.version = "1.1.0"
8
+ spec.version = "2.0.2"
9
9
  spec.authors = %w[fiscal-cliff umbrellio]
10
10
  spec.email = ["oss@umbrellio.biz"]
11
- spec.required_ruby_version = ">= 2.6"
11
+ spec.required_ruby_version = ">= 2.7"
12
12
 
13
13
  spec.summary = "The extension mimics AR5 batches api"
14
14
  spec.description = "Allows you to split your dataset in batches"
@@ -22,13 +22,11 @@ Gem::Specification.new do |spec|
22
22
 
23
23
  spec.add_development_dependency "bundler"
24
24
  spec.add_development_dependency "bundler-audit"
25
-
25
+ spec.add_development_dependency "pg"
26
26
  spec.add_development_dependency "pry"
27
27
  spec.add_development_dependency "rake"
28
-
29
- spec.add_development_dependency "rubocop-config-umbrellio"
30
-
31
28
  spec.add_development_dependency "rspec"
29
+ spec.add_development_dependency "rubocop-config-umbrellio"
32
30
  spec.add_development_dependency "simplecov"
33
31
  spec.add_development_dependency "simplecov-lcov"
34
32
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sequel-batches
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 2.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - fiscal-cliff
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2022-08-05 00:00:00.000000000 Z
12
+ date: 2022-08-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sequel
@@ -53,6 +53,20 @@ dependencies:
53
53
  - - ">="
54
54
  - !ruby/object:Gem::Version
55
55
  version: '0'
56
+ - !ruby/object:Gem::Dependency
57
+ name: pg
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
56
70
  - !ruby/object:Gem::Dependency
57
71
  name: pry
58
72
  requirement: !ruby/object:Gem::Requirement
@@ -82,7 +96,7 @@ dependencies:
82
96
  - !ruby/object:Gem::Version
83
97
  version: '0'
84
98
  - !ruby/object:Gem::Dependency
85
- name: rubocop-config-umbrellio
99
+ name: rspec
86
100
  requirement: !ruby/object:Gem::Requirement
87
101
  requirements:
88
102
  - - ">="
@@ -96,7 +110,7 @@ dependencies:
96
110
  - !ruby/object:Gem::Version
97
111
  version: '0'
98
112
  - !ruby/object:Gem::Dependency
99
- name: rspec
113
+ name: rubocop-config-umbrellio
100
114
  requirement: !ruby/object:Gem::Requirement
101
115
  requirements:
102
116
  - - ">="
@@ -150,6 +164,7 @@ files:
150
164
  - ".rubocop.yml"
151
165
  - CODE_OF_CONDUCT.md
152
166
  - Gemfile
167
+ - Gemfile.lock
153
168
  - LICENSE.txt
154
169
  - README.md
155
170
  - Rakefile
@@ -169,7 +184,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
169
184
  requirements:
170
185
  - - ">="
171
186
  - !ruby/object:Gem::Version
172
- version: '2.6'
187
+ version: '2.7'
173
188
  required_rubygems_version: !ruby/object:Gem::Requirement
174
189
  requirements:
175
190
  - - ">="