sequel-batches 1.0.0 → 1.0.1

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: e24dcc9f437a98a65709c2486c46e6e3ddbeb89a1d3298af245c4d20ae758492
4
- data.tar.gz: 5d5670cc31a6afcf7cdee391dc889c9636e9a201fe1f68e01860df2174e462fd
3
+ metadata.gz: 75f26b2a799694f8ab7c27d9b2e9fdbf12990d92c3c9a5ba2117ec9c7815cb47
4
+ data.tar.gz: be0eb9ffc65170761b2000c20c2c8e628c8eacc2cfbf1cee7d4fbf54c0134760
5
5
  SHA512:
6
- metadata.gz: 90f54e68d80fe0872415ab53b4d217c803eaf1d711e083bc518799475c805cd050d2a5605d42603b959fcde28ddfb5ef679344f46bd601677a31ab192bf4b4aa
7
- data.tar.gz: a7f69e996cdedfec3b83160b15858fb090c970d2e33516fe53c2e64e1c2c5ed5d198241ea6836352cd1a3f260ebae8667b79bcd4847e6d08e4556c22a996a306
6
+ metadata.gz: 874d85e620b0d5cbe2a82700deff251edf004bca67a64e89ece8fca769abcbc5f117891d02767f0873634156de7680558cfeceee0abd917f7a762c8f5720c42c
7
+ data.tar.gz: 39ca7cd7e363ab3fe6d8d04ef7c73f140369f3e0e6a87c8d79605d6c80882c2bcbc0fb625ee8dccc8d297f20d5516c031b126c82cbcc38f3d291474ccbe226be
@@ -5,5 +5,5 @@ AllCops:
5
5
  DisplayCopNames: true
6
6
  TargetRubyVersion: 2.3
7
7
 
8
- Naming/UncommunicativeMethodParamName:
8
+ Naming/MethodParameterName:
9
9
  Enabled: false
data/README.md CHANGED
@@ -4,22 +4,6 @@ This dataset extension provides the `#in_batches` method. The method splits data
4
4
 
5
5
  Note: currently only PostgreSQL database is supported.
6
6
 
7
- You can set the following options:
8
-
9
- ### pk
10
- 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`.
11
-
12
- 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.
13
-
14
- ### of
15
- Sets chunk size (1000 by default).
16
-
17
- ### start
18
- 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).
19
-
20
- ### finish
21
- Same as `start` but represents the frame end.
22
-
23
7
  ## Installation
24
8
 
25
9
  Add this line to your application's Gemfile:
@@ -67,6 +51,24 @@ Event.where(type: "login").in_batches(options) do |ds|
67
51
  end
68
52
  ```
69
53
 
54
+ ## Options
55
+
56
+ You can set the following options:
57
+
58
+ ### pk
59
+ 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`.
60
+
61
+ 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.
62
+
63
+ ### of
64
+ Sets chunk size (1000 by default).
65
+
66
+ ### start
67
+ 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).
68
+
69
+ ### finish
70
+ Same as `start` but represents the frame end.
71
+
70
72
  ## Contributing
71
73
 
72
74
  Bug reports and pull requests are welcome on GitHub at https://github.com/umbrellio/sequel-batches.
@@ -26,7 +26,8 @@ module Sequel::Extensions::Batches
26
26
  base_ds
27
27
  end
28
28
 
29
- current_instance = db.from(working_ds.limit(of)).select(*pk).order(*pk).last or break
29
+ working_ds_pk = working_ds.select(*qualified_pk).limit(of)
30
+ current_instance = db.from(working_ds_pk).select(*pk).order(*pk).last or break
30
31
  working_ds = working_ds.where(generate_conditions(current_instance.to_h, sign: :<=))
31
32
 
32
33
  yield working_ds
@@ -67,7 +68,7 @@ module Sequel::Extensions::Batches
67
68
  base_ds = base_ds.where(generate_conditions(check_pk(start), sign: :>=)) if start
68
69
  base_ds = base_ds.where(generate_conditions(check_pk(finish), sign: :<=)) if finish
69
70
 
70
- pk_ds = db.from(base_ds).select(*pk).order(*pk)
71
+ pk_ds = db.from(base_ds.select(*qualified_pk)).select(*pk).order(*pk)
71
72
  actual_start = pk_ds.first
72
73
  actual_finish = pk_ds.last
73
74
 
@@ -5,8 +5,8 @@ $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.0.0"
9
- spec.authors = ["fiscal-cliff", "umbrellio"]
8
+ spec.version = "1.0.1"
9
+ spec.authors = %w[fiscal-cliff umbrellio]
10
10
  spec.email = ["oss@umbrellio.biz"]
11
11
 
12
12
  spec.summary = "The extension mimics AR5 batches api"
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.0.0
4
+ version: 1.0.1
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: 2019-08-19 00:00:00.000000000 Z
12
+ date: 2020-05-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sequel
@@ -162,7 +162,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
162
162
  - !ruby/object:Gem::Version
163
163
  version: '0'
164
164
  requirements: []
165
- rubygems_version: 3.0.3
165
+ rubygems_version: 3.1.2
166
166
  signing_key:
167
167
  specification_version: 4
168
168
  summary: The extension mimics AR5 batches api