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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/sequel/extensions/batches/yielder.rb +11 -7
- data/sequel-batches.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3cd6e15b3473080a3ccc2db4959cddb601624fc0bde9bda3bfad153d9e60194b
|
4
|
+
data.tar.gz: 840ea07efcc58c518a2022f21e4423fc1e2887b2a552c05d5905077ae02daa8a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a1ae993708db8f425d9901047fb868498f0b1e0957e2fc56578ec23f388e095fd2ba509a3a09c7b9d485c9b7f7e1bf390144bc2e74c09bf585c7b4b708376b24
|
7
|
+
data.tar.gz: 5d19d482faf0959d6a873dd17dc62595c7d5c972d1d35d169ece1c53f880d5ba1e116b6db5d27e04e3731c2f74da989ac361df215fe9d2daa061a2c6b9e43f69
|
data/Gemfile.lock
CHANGED
@@ -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 :
|
74
|
-
asc_order? ?
|
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
|
|
data/sequel-batches.gemspec
CHANGED
@@ -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.
|
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.
|
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-
|
12
|
+
date: 2022-08-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sequel
|