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 +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +2 -2
- data/lib/spring_onion/config.rb +2 -2
- data/lib/spring_onion/explainer.rb +6 -6
- data/lib/spring_onion/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 797e6837cbc8fb508afac284d54509ce175ac77346320bcc0697c0cd54b49a06
|
4
|
+
data.tar.gz: 487f8a88353cce686f0b259cd83f2401cb3d599a4d05e403250018b2e3ae4fdc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bc53955a16cd100e68ef306b798966f62937963ce8a3a67b819779379892fa50125b61c30e127cd1d1c3c0bd23cf58b9961a13a196430b15f55705b553ec9f0e
|
7
|
+
data.tar.gz: d0c482e0864d25b05d3dc002de0b36d6b6b2d5414d8af7402bf86390f7a1182dc2d0cd745afb6cd8dcfe5d4c889141c351f4d3f6414acd957c4d2bd43322af41
|
data/Gemfile.lock
CHANGED
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}],"
|
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
|
-
"
|
68
|
+
"warnings": {
|
69
69
|
"line 1": [
|
70
70
|
"slow_type"
|
71
71
|
]
|
data/lib/spring_onion/config.rb
CHANGED
@@ -17,7 +17,7 @@ module SpringOnion
|
|
17
17
|
'Using temporary'
|
18
18
|
)
|
19
19
|
|
20
|
-
@
|
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
|
-
:
|
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
|
-
|
34
|
-
|
33
|
+
warnings = SpringOnion.warnings
|
34
|
+
warning_names_by_line = {}
|
35
35
|
|
36
36
|
exp.each_with_index do |row, i|
|
37
|
-
|
37
|
+
warning_names = warnings.select do |_name, validator|
|
38
38
|
validator.call(row)
|
39
39
|
end.keys
|
40
40
|
|
41
|
-
|
41
|
+
warning_names_by_line["line #{i + 1}"] = warning_names unless warning_names.empty?
|
42
42
|
end
|
43
43
|
|
44
|
-
return if
|
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
|
-
|
49
|
+
warnings: warning_names_by_line,
|
50
50
|
backtrace: trace.slice(0, SpringOnion.trace_len),
|
51
51
|
}
|
52
52
|
|
data/lib/spring_onion/version.rb
CHANGED