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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2cefe4d1a0d3a7a285526c35c6ead450994578721eb35bbc350ba3fc1e6154d6
4
- data.tar.gz: b143544e5f799dc35d174378512107fdb978cfb73392eca0f921ea304388bb5a
3
+ metadata.gz: 6eb6d3a03ffce49b32f78bb04809b3ce0b9c0cd114c3e32dae441c815873c8a5
4
+ data.tar.gz: 1b5426e4d320baed476489d56928480d46604028b798a975faa7d104533d7606
5
5
  SHA512:
6
- metadata.gz: 00f8b8f8bcf82e7cdc376119a45258280a7c9dbcedf97b84331191ee1fd3a0e745137927eb60b36fff86e790078ac9622219a524e9b1e3deb1a724cd6d030182
7
- data.tar.gz: 320a553062bec7fa8d4cd3428806fa30ffefcbc2fb141975076a9cd0895f50020b8c82741936a40d1c389921a67a326579cd7c55c870b25fc29d99e90cafd7b5
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
@@ -0,0 +1,16 @@
1
+ require:
2
+ - rubocop-rubycw
3
+
4
+ AllCops:
5
+ TargetRubyVersion: 2.7
6
+ DisabledByDefault: true
7
+
8
+ Rubycw/Rubycw:
9
+ Enabled: true
10
+ Exclude:
11
+ - 'test/**/*_test.rb'
12
+
13
+ Lint/DuplicateMethods:
14
+ Enabled: true
15
+ Include:
16
+ - 'test/**/*_test.rb'
data/Gemfile.lock CHANGED
@@ -1,45 +1,61 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- top_n_loader (1.0.1)
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 (6.0.2.1)
11
- activesupport (= 6.0.2.1)
12
- activerecord (6.0.2.1)
13
- activemodel (= 6.0.2.1)
14
- activesupport (= 6.0.2.1)
15
- activesupport (6.0.2.1)
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 (>= 0.7, < 2)
18
- minitest (~> 5.1)
19
- tzinfo (~> 1.1)
20
- zeitwerk (~> 2.2)
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.5)
22
+ concurrent-ruby (1.1.9)
23
23
  docile (1.1.5)
24
- i18n (1.7.0)
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
- thread_safe (0.3.6)
40
- tzinfo (1.2.6)
41
- thread_safe (~> 0.1)
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.2
75
+ 2.1.4
data/Rakefile CHANGED
@@ -7,4 +7,9 @@ Rake::TestTask.new(:test) do |t|
7
7
  t.test_files = FileList["test/**/*_test.rb"]
8
8
  end
9
9
 
10
- task :default => :test
10
+ desc "Run rubocop"
11
+ task :rubocop do
12
+ sh 'bundle exec rubocop'
13
+ end
14
+
15
+ task default: [:rubocop, :test]
@@ -0,0 +1,8 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in top_n_loader.gemspec
6
+ gemspec path: ".."
7
+
8
+ gem "activerecord", "~> 5.2.0"
@@ -0,0 +1,8 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in top_n_loader.gemspec
6
+ gemspec path: ".."
7
+
8
+ gem "activerecord", "~> 6.0.0"
@@ -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 last_value
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.last_value IS NULL
37
- OR #{qt target_table}.#{q order_key} #{{ asc: :<=, desc: :>= }[order_mode]} T.last_value
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 last_value
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.last_value IS NULL
72
- OR #{qt table_name}.#{q order_key} #{order_op} T.last_value
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}
@@ -1,3 +1,3 @@
1
1
  module TopNLoader
2
- VERSION = '1.0.1'
2
+ VERSION = '1.0.2'
3
3
  end
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.1
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: 2020-01-05 00:00:00.000000000 Z
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.1.2
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: []