n_one 1.0.0 → 1.0.1

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: b2b2ba1b5d986f35ed074dac942c0448f1ae64217403a5946398da54ad93e54f
4
- data.tar.gz: 14cbea5e0fd6b84932f5d8b74957f8d99e97b0572eb062af824c9cf41745be0d
3
+ metadata.gz: d037a52ad1770b38646937c04fdf274fac7dfdbf5d8351eb5208e0899d4d8927
4
+ data.tar.gz: eafb63f23fca359806b398c41480bad4225a46a1806dcbf05d50d88ca8fec197
5
5
  SHA512:
6
- metadata.gz: ea4606afb1b0ef8cc5417745f76b7260b628e77c645896e6ba919096340692cf6602a5d7645133fe5dbf79021d0664a738b6e870bbbea72728b6cb514bac638e
7
- data.tar.gz: '08567625417d3881bc257bde3da51db8e500eb06a2ffdc2dd32d2800026d8d00df6a9ffb81cc6638d66bb96bde769f015c231a31a0444e7e8deb9b84c4efda04'
6
+ metadata.gz: 1e18c871f74065f1fac610a11a70717a6bd91caf447062627d91b847602300ac76abae5b7a5200d57dd65ad223f2da6fe6554ff7f0ae97df07710c609d9591e8
7
+ data.tar.gz: 4b933072d3e7e62f6abfac60ea794d64049457c756497614ce2f84eb77687d008786e901bdfb1139f5b47a5b49ed9acddafd7cf036e80a6e9620d977bee45a95
@@ -4,7 +4,7 @@ jobs:
4
4
  test:
5
5
  strategy:
6
6
  matrix:
7
- ruby: [2.5, '3.0', head]
7
+ ruby: [2.6, '3.0']
8
8
  runs-on: ubuntu-latest
9
9
  steps:
10
10
  - uses: actions/checkout@v2
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- n_one (1.0.0)
4
+ n_one (1.0.1)
5
5
  pg_query
6
6
 
7
7
  GEM
@@ -23,6 +23,8 @@ GEM
23
23
  concurrent-ruby (1.1.8)
24
24
  factory_bot (6.1.0)
25
25
  activesupport (>= 5.0.0)
26
+ google-protobuf (3.19.1)
27
+ google-protobuf (3.19.1-x86_64-linux)
26
28
  i18n (1.8.9)
27
29
  concurrent-ruby (~> 1.0)
28
30
  method_source (1.0.0)
@@ -30,7 +32,8 @@ GEM
30
32
  parallel (1.20.1)
31
33
  parser (3.0.1.0)
32
34
  ast (~> 2.4.1)
33
- pg_query (1.3.0)
35
+ pg_query (2.1.2)
36
+ google-protobuf (>= 3.17.1)
34
37
  pry (0.14.0)
35
38
  coderay (~> 1.1)
36
39
  method_source (~> 1.0)
data/README.md CHANGED
@@ -74,11 +74,23 @@ end
74
74
  Ignore notifications for call stacks containing one or more substrings:
75
75
 
76
76
  ```ruby
77
- NOne.scan!(whitelist: 'myapp/lib/known_n_plus_ones/') do
77
+ NOne.scan!(whitelist: ['myapp/lib/known_n_plus_ones/']) do
78
78
  example.run
79
79
  end
80
80
  ```
81
81
 
82
+ ## Ignore names
83
+
84
+ Ignore queries with names:
85
+
86
+ ```ruby
87
+ NOne.scan!(ignore_names: ['SCHEMA']) do
88
+ example.run
89
+ end
90
+ ```
91
+
92
+ It will skip schema queries(e.g. for column names of a given table)
93
+
82
94
  ## Contributing
83
95
 
84
96
  Bug reports and pull requests are welcome on GitHub at https://github.com/prikha/n_one.
data/lib/n_one/runner.rb CHANGED
@@ -2,8 +2,14 @@
2
2
 
3
3
  module NOne
4
4
  class Runner # :nodoc:
5
- def initialize(whitelist: [])
5
+ # Instantiation
6
+ #
7
+ # @param whitelist [<String>] frame substrings to be ignored
8
+ # @param ignore_names [<String>] query names to be ignored
9
+ #
10
+ def initialize(whitelist: [], ignore_names: [])
6
11
  @whitelist = ['active_record/validations/uniqueness'] + whitelist
12
+ @ignore_names = ignore_names
7
13
  end
8
14
 
9
15
  def scan(&block)
@@ -20,7 +26,7 @@ module NOne
20
26
 
21
27
  private
22
28
 
23
- attr_reader :store, :whitelist
29
+ attr_reader :store, :whitelist, :ignore_names
24
30
 
25
31
  def init_store
26
32
  @store = {}
@@ -51,6 +57,7 @@ module NOne
51
57
  cached = data[:cached]
52
58
 
53
59
  next if !sql.include?('SELECT') || cached
60
+ next if ignore_names.include?(data[:name])
54
61
 
55
62
  sql_fingerprint = Query.fingerprint(sql)
56
63
  next unless sql_fingerprint
data/lib/n_one/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module NOne
4
- VERSION = '1.0.0'
4
+ VERSION = '1.0.1'
5
5
  end
data/lib/n_one.rb CHANGED
@@ -30,11 +30,11 @@ module NOne
30
30
 
31
31
  module_function
32
32
 
33
- def scan(whitelist: [], &block)
34
- Runner.new(whitelist: whitelist).scan(&block)
33
+ def scan(**args, &block)
34
+ Runner.new(**args).scan(&block)
35
35
  end
36
36
 
37
- def scan!(whitelist: [], &block)
38
- Runner.new(whitelist: whitelist).scan!(&block)
37
+ def scan!(**args, &block)
38
+ Runner.new(**args).scan!(&block)
39
39
  end
40
40
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: n_one
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
  - Sergey Prikhodko
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-08-23 00:00:00.000000000 Z
11
+ date: 2021-12-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pg_query
@@ -66,7 +66,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
66
66
  - !ruby/object:Gem::Version
67
67
  version: '0'
68
68
  requirements: []
69
- rubygems_version: 3.1.2
69
+ rubygems_version: 3.0.3.1
70
70
  signing_key:
71
71
  specification_version: 4
72
72
  summary: N+1 auto-detection for ActiveRecord and PostgreSQL