sequel-batches 2.0.1 → 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: 0d8af97c53f8431d8fc6318af40c5f42e00ad83f177dc663fbdd5c0a18f7c90d
4
- data.tar.gz: 1f5d637fff098d001694c62a4e397801a5077217ba2174533a8c87975edc8fb7
3
+ metadata.gz: 3cd6e15b3473080a3ccc2db4959cddb601624fc0bde9bda3bfad153d9e60194b
4
+ data.tar.gz: 840ea07efcc58c518a2022f21e4423fc1e2887b2a552c05d5905077ae02daa8a
5
5
  SHA512:
6
- metadata.gz: f26a92d8573d15f3a264d606cce33eaeab69bdb0a791d9b98b4dc9cb8cfad8c4abddf0b04bd5ff9032fe80042da81cc81d1b8759b662c4459567d6720f2bfb7c
7
- data.tar.gz: 237d285d2febaa6f896f4e7d727a0a36884c6889c348ef68815999ee10c766390f490888adf62eda75f2a41789e93bddd0dcb205279003eba46db6dba570ff42
6
+ metadata.gz: a1ae993708db8f425d9901047fb868498f0b1e0957e2fc56578ec23f388e095fd2ba509a3a09c7b9d485c9b7f7e1bf390144bc2e74c09bf585c7b4b708376b24
7
+ data.tar.gz: 5d19d482faf0959d6a873dd17dc62595c7d5c972d1d35d169ece1c53f880d5ba1e116b6db5d27e04e3731c2f74da989ac361df215fe9d2daa061a2c6b9e43f69
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sequel-batches (2.0.1)
4
+ sequel-batches (2.0.2)
5
5
  sequel
6
6
 
7
7
  GEM
@@ -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(qualified: true)).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,7 +5,7 @@ $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 = "2.0.1"
8
+ spec.version = "2.0.2"
9
9
  spec.authors = %w[fiscal-cliff umbrellio]
10
10
  spec.email = ["oss@umbrellio.biz"]
11
11
  spec.required_ruby_version = ">= 2.7"
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: 2.0.1
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-09 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