spring_onion 0.1.4 → 0.2.0

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: 5dc46f208b6c23dee53529598492e790c4b7335a694540312932b27eb4613889
4
- data.tar.gz: d94debb3984be7370cefccd527e38ae56d90fcef1a42fac8277b011a171359bd
3
+ metadata.gz: 797e6837cbc8fb508afac284d54509ce175ac77346320bcc0697c0cd54b49a06
4
+ data.tar.gz: 487f8a88353cce686f0b259cd83f2401cb3d599a4d05e403250018b2e3ae4fdc
5
5
  SHA512:
6
- metadata.gz: 89f5da00f467539f3829439824b3610886893e3cf7b47ada519f178d96b99e85b07885c3390e05a1a15c3850038625a5ae2e3bed64bd1ac19cf34538dd2a2bac
7
- data.tar.gz: be8e4de6c3fd4a4e5758761047f57eb6145fc0739911171756092c2006479d1d4d742262bbd485275ceae7844684b3cf389e76785b08977811e6b0b25a09e377
6
+ metadata.gz: bc53955a16cd100e68ef306b798966f62937963ce8a3a67b819779379892fa50125b61c30e127cd1d1c3c0bd23cf58b9961a13a196430b15f55705b553ec9f0e
7
+ data.tar.gz: d0c482e0864d25b05d3dc002de0b36d6b6b2d5414d8af7402bf86390f7a1182dc2d0cd745afb6cd8dcfe5d4c889141c351f4d3f6414acd957c4d2bd43322af41
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- spring_onion (0.1.4)
4
+ spring_onion (0.2.0)
5
5
  activerecord
6
6
  coderay
7
7
  mysql2
data/README.md CHANGED
@@ -40,7 +40,7 @@ SpringOnion.source_filter_re = //
40
40
  class Employee < ActiveRecord::Base; end
41
41
 
42
42
  Employee.all.to_a.count
43
- #=> SpringOnion INFO 2020-07-18 01:53:27 +0900 {"sql":"SELECT `employees`.* FROM `employees`","explain":[{"line":1,"select_type":"SIMPLE","table":"employees","partitions":null,"type":"ALL","possible_keys":null,"key":null,"key_len":null,"ref":null,"rows":298936,"filtered":100.0,"Extra":null}],"violations":{"line 1":["slow_type"]},"backtrace":["/foo/bar/zoo/baz.rb:18:in `\u003ctop (required)\u003e'"]}
43
+ #=> SpringOnion INFO 2020-07-18 01:53:27 +0900 {"sql":"SELECT `employees`.* FROM `employees`","explain":[{"line":1,"select_type":"SIMPLE","table":"employees","partitions":null,"type":"ALL","possible_keys":null,"key":null,"key_len":null,"ref":null,"rows":298936,"filtered":100.0,"Extra":null}],"warnings":{"line 1":["slow_type"]},"backtrace":["/foo/bar/zoo/baz.rb:18:in `\u003ctop (required)\u003e'"]}
44
44
  #=> 300024
45
45
  ```
46
46
 
@@ -65,7 +65,7 @@ Employee.all.to_a.count
65
65
  "Extra": null
66
66
  }
67
67
  ],
68
- "violations": {
68
+ "warnings": {
69
69
  "line 1": [
70
70
  "slow_type"
71
71
  ]
@@ -17,7 +17,7 @@ module SpringOnion
17
17
  'Using temporary'
18
18
  )
19
19
 
20
- @violations = {
20
+ @warnings = {
21
21
  slow_select_type: ->(exp) { SLOW_SELECT_TYPE_RE =~ exp['select_type'] },
22
22
  slow_type: ->(exp) { SLOW_TYPE_RE =~ exp['type'] },
23
23
  slow_possible_keys: ->(exp) { SLOW_POSSIBLE_KEYS_RE =~ exp['possible_keys'] },
@@ -75,7 +75,7 @@ module SpringOnion
75
75
  class << self
76
76
  attr_accessor :enabled,
77
77
  :connection,
78
- :violations,
78
+ :warnings,
79
79
  :sql_filter_re, :ignore_sql_filter_re, :sql_filter,
80
80
  :source_filter_re, :ignore_source_filter_re, :source_filter,
81
81
  :logger,
@@ -30,23 +30,23 @@ module SpringOnion
30
30
  end
31
31
 
32
32
  def _validate(exp, sql, trace)
33
- violations = SpringOnion.violations
34
- violation_names_by_line = {}
33
+ warnings = SpringOnion.warnings
34
+ warning_names_by_line = {}
35
35
 
36
36
  exp.each_with_index do |row, i|
37
- violation_names = violations.select do |_name, validator|
37
+ warning_names = warnings.select do |_name, validator|
38
38
  validator.call(row)
39
39
  end.keys
40
40
 
41
- violation_names_by_line["line #{i + 1}"] = violation_names unless violation_names.empty?
41
+ warning_names_by_line["line #{i + 1}"] = warning_names unless warning_names.empty?
42
42
  end
43
43
 
44
- return if violation_names_by_line.empty?
44
+ return if warning_names_by_line.empty?
45
45
 
46
46
  h = {
47
47
  sql: sql,
48
48
  explain: exp.each_with_index.map { |r, i| { line: i + 1 }.merge(r) },
49
- violations: violation_names_by_line,
49
+ warnings: warning_names_by_line,
50
50
  backtrace: trace.slice(0, SpringOnion.trace_len),
51
51
  }
52
52
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SpringOnion
4
- VERSION = '0.1.4'
4
+ VERSION = '0.2.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spring_onion
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - winebarrel