top_n_loader 1.0.1 → 1.0.2
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 +4 -4
- data/.github/workflows/test.yml +27 -0
- data/.rubocop.yml +16 -0
- data/Gemfile.lock +36 -18
- data/Rakefile +6 -1
- data/gemfiles/Gemfile-rails-5.2 +8 -0
- data/gemfiles/Gemfile-rails-6.0 +8 -0
- data/lib/top_n_loader/sql_builder.rb +6 -6
- data/lib/top_n_loader/version.rb +1 -1
- data/top_n_loader.gemspec +1 -1
- metadata +38 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6eb6d3a03ffce49b32f78bb04809b3ce0b9c0cd114c3e32dae441c815873c8a5
|
4
|
+
data.tar.gz: 1b5426e4d320baed476489d56928480d46604028b798a975faa7d104533d7606
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7adc3640113ca456040bfcdc08c1c35d9c9ed18d7ddc54d865785ee8a49a06531b2c0067ae84f90ecb5198c088683226892e6c03e3b38edbdcd48635d669dc7a
|
7
|
+
data.tar.gz: f6c99dac0cbe3cd32fc02393f085baf853d88f8680b848e99efccf42ce9eebfffd7a8605192a04e75a396e45bda642a53a0372aa78241101b12680d6d93e6a8a
|
@@ -0,0 +1,27 @@
|
|
1
|
+
name: Test
|
2
|
+
on: [push, pull_request]
|
3
|
+
jobs:
|
4
|
+
test:
|
5
|
+
strategy:
|
6
|
+
fail-fast: false
|
7
|
+
matrix:
|
8
|
+
ruby: [ '2.5', '2.6', '2.7' ]
|
9
|
+
gemfiles:
|
10
|
+
- gemfiles/Gemfile-rails-5.2
|
11
|
+
- gemfiles/Gemfile-rails-6.0
|
12
|
+
exclude:
|
13
|
+
- ruby: '2.6'
|
14
|
+
gemfiles: gemfiles/Gemfile-rails-5.2
|
15
|
+
- ruby: '2.7'
|
16
|
+
gemfiles: gemfiles/Gemfile-rails-5.2
|
17
|
+
runs-on: ubuntu-latest
|
18
|
+
steps:
|
19
|
+
- uses: actions/checkout@v2
|
20
|
+
- uses: ruby/setup-ruby@v1
|
21
|
+
with:
|
22
|
+
ruby-version: ${{ matrix.ruby }}
|
23
|
+
- run: |
|
24
|
+
sudo apt-get update
|
25
|
+
sudo apt-get install -y libsqlite3-dev
|
26
|
+
- run: bundle install --gemfile ${{ matrix.gemfiles }} --jobs 4 --retry 3
|
27
|
+
- run: bundle exec --gemfile ${{ matrix.gemfiles }} rake
|
data/.rubocop.yml
ADDED
data/Gemfile.lock
CHANGED
@@ -1,45 +1,61 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
top_n_loader (1.0.
|
4
|
+
top_n_loader (1.0.2)
|
5
5
|
activerecord
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
-
activemodel (
|
11
|
-
activesupport (=
|
12
|
-
activerecord (
|
13
|
-
activemodel (=
|
14
|
-
activesupport (=
|
15
|
-
activesupport (
|
10
|
+
activemodel (7.0.1)
|
11
|
+
activesupport (= 7.0.1)
|
12
|
+
activerecord (7.0.1)
|
13
|
+
activemodel (= 7.0.1)
|
14
|
+
activesupport (= 7.0.1)
|
15
|
+
activesupport (7.0.1)
|
16
16
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
17
|
-
i18n (>=
|
18
|
-
minitest (
|
19
|
-
tzinfo (~>
|
20
|
-
|
17
|
+
i18n (>= 1.6, < 2)
|
18
|
+
minitest (>= 5.1)
|
19
|
+
tzinfo (~> 2.0)
|
20
|
+
ast (2.4.0)
|
21
21
|
coderay (1.1.2)
|
22
|
-
concurrent-ruby (1.1.
|
22
|
+
concurrent-ruby (1.1.9)
|
23
23
|
docile (1.1.5)
|
24
|
-
i18n (1.
|
24
|
+
i18n (1.8.11)
|
25
25
|
concurrent-ruby (~> 1.0)
|
26
|
+
jaro_winkler (1.5.4)
|
26
27
|
json (2.1.0)
|
27
28
|
method_source (0.9.0)
|
28
29
|
minitest (5.11.3)
|
30
|
+
parallel (1.19.1)
|
31
|
+
parser (2.7.1.2)
|
32
|
+
ast (~> 2.4.0)
|
29
33
|
pry (0.11.3)
|
30
34
|
coderay (~> 1.1.0)
|
31
35
|
method_source (~> 0.9.0)
|
36
|
+
rainbow (3.0.0)
|
32
37
|
rake (10.5.0)
|
38
|
+
rexml (3.2.4)
|
39
|
+
rubocop (0.82.0)
|
40
|
+
jaro_winkler (~> 1.5.1)
|
41
|
+
parallel (~> 1.10)
|
42
|
+
parser (>= 2.7.0.1)
|
43
|
+
rainbow (>= 2.2.2, < 4.0)
|
44
|
+
rexml
|
45
|
+
ruby-progressbar (~> 1.7)
|
46
|
+
unicode-display_width (>= 1.4.0, < 2.0)
|
47
|
+
rubocop-rubycw (0.1.4)
|
48
|
+
rubocop
|
49
|
+
ruby-progressbar (1.10.1)
|
33
50
|
simplecov (0.15.1)
|
34
51
|
docile (~> 1.1.0)
|
35
52
|
json (>= 1.8, < 3)
|
36
53
|
simplecov-html (~> 0.10.0)
|
37
54
|
simplecov-html (0.10.2)
|
38
55
|
sqlite3 (1.4.2)
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
zeitwerk (2.2.2)
|
56
|
+
tzinfo (2.0.4)
|
57
|
+
concurrent-ruby (~> 1.0)
|
58
|
+
unicode-display_width (1.7.0)
|
43
59
|
|
44
60
|
PLATFORMS
|
45
61
|
ruby
|
@@ -49,9 +65,11 @@ DEPENDENCIES
|
|
49
65
|
minitest
|
50
66
|
pry
|
51
67
|
rake
|
68
|
+
rubocop
|
69
|
+
rubocop-rubycw
|
52
70
|
simplecov
|
53
71
|
sqlite3
|
54
72
|
top_n_loader!
|
55
73
|
|
56
74
|
BUNDLED WITH
|
57
|
-
2.1.
|
75
|
+
2.1.4
|
data/Rakefile
CHANGED
@@ -28,13 +28,13 @@ module TopNLoader::SQLBuilder
|
|
28
28
|
WHERE #{qt parent_table}.#{q klass.primary_key} = T.#{q klass.primary_key}
|
29
29
|
ORDER BY #{qt target_table}.#{q order_key} #{order_mode.upcase}
|
30
30
|
LIMIT 1 OFFSET #{limit.to_i - 1}
|
31
|
-
) AS
|
31
|
+
) AS last_value_of_key
|
32
32
|
FROM #{qt parent_table} as T where T.#{q klass.primary_key} in (?)
|
33
33
|
) T
|
34
34
|
ON #{qt parent_table}.#{q klass.primary_key} = T.top_n_group_key
|
35
35
|
AND (
|
36
|
-
T.
|
37
|
-
OR #{qt target_table}.#{q order_key} #{{ asc: :<=, desc: :>= }[order_mode]} T.
|
36
|
+
T.last_value_of_key IS NULL
|
37
|
+
OR #{qt target_table}.#{q order_key} #{{ asc: :<=, desc: :>= }[order_mode]} T.last_value_of_key
|
38
38
|
OR #{qt target_table}.#{q order_key} is NULL
|
39
39
|
)
|
40
40
|
)
|
@@ -63,13 +63,13 @@ module TopNLoader::SQLBuilder
|
|
63
63
|
#{"AND #{sql}" if sql}
|
64
64
|
ORDER BY #{qt table_name}.#{q order_key} #{order_mode.to_s.upcase}
|
65
65
|
LIMIT 1 OFFSET #{limit.to_i - 1}
|
66
|
-
) AS
|
66
|
+
) AS last_value_of_key
|
67
67
|
FROM #{group_key_table}
|
68
68
|
) T
|
69
69
|
ON #{join_cond}
|
70
70
|
AND (
|
71
|
-
T.
|
72
|
-
OR #{qt table_name}.#{q order_key} #{order_op} T.
|
71
|
+
T.last_value_of_key IS NULL
|
72
|
+
OR #{qt table_name}.#{q order_key} #{order_op} T.last_value_of_key
|
73
73
|
OR #{qt table_name}.#{q order_key} is NULL
|
74
74
|
)
|
75
75
|
#{"WHERE #{sql}" if sql}
|
data/lib/top_n_loader/version.rb
CHANGED
data/top_n_loader.gemspec
CHANGED
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
|
|
22
22
|
|
23
23
|
spec.add_dependency "activerecord"
|
24
24
|
|
25
|
-
%w[bundler rake minitest sqlite3 pry simplecov].each do |gem_name|
|
25
|
+
%w[bundler rake minitest sqlite3 pry simplecov rubocop rubocop-rubycw].each do |gem_name|
|
26
26
|
spec.add_development_dependency gem_name
|
27
27
|
end
|
28
28
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: top_n_loader
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- tompng
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -108,6 +108,34 @@ dependencies:
|
|
108
108
|
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rubocop
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: rubocop-rubycw
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
111
139
|
description: load top n records for each group
|
112
140
|
email:
|
113
141
|
- tomoyapenguin@gmail.com
|
@@ -115,7 +143,9 @@ executables: []
|
|
115
143
|
extensions: []
|
116
144
|
extra_rdoc_files: []
|
117
145
|
files:
|
146
|
+
- ".github/workflows/test.yml"
|
118
147
|
- ".gitignore"
|
148
|
+
- ".rubocop.yml"
|
119
149
|
- ".travis.yml"
|
120
150
|
- Gemfile
|
121
151
|
- Gemfile.lock
|
@@ -124,6 +154,8 @@ files:
|
|
124
154
|
- Rakefile
|
125
155
|
- bin/console
|
126
156
|
- bin/setup
|
157
|
+
- gemfiles/Gemfile-rails-5.2
|
158
|
+
- gemfiles/Gemfile-rails-6.0
|
127
159
|
- lib/top_n_loader.rb
|
128
160
|
- lib/top_n_loader/sql_builder.rb
|
129
161
|
- lib/top_n_loader/version.rb
|
@@ -132,7 +164,7 @@ homepage: https://github.com/tompng/top_n_loader
|
|
132
164
|
licenses:
|
133
165
|
- MIT
|
134
166
|
metadata: {}
|
135
|
-
post_install_message:
|
167
|
+
post_install_message:
|
136
168
|
rdoc_options: []
|
137
169
|
require_paths:
|
138
170
|
- lib
|
@@ -147,8 +179,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
147
179
|
- !ruby/object:Gem::Version
|
148
180
|
version: '0'
|
149
181
|
requirements: []
|
150
|
-
rubygems_version: 3.
|
151
|
-
signing_key:
|
182
|
+
rubygems_version: 3.3.3
|
183
|
+
signing_key:
|
152
184
|
specification_version: 4
|
153
185
|
summary: load top n records for each group
|
154
186
|
test_files: []
|