testscore 1.0.3 → 1.0.4
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/lib/testscore.rb +33 -35
- 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: c4adacb3059c55fd6a79733c2e24d5acc797911b5492fa9cef55ecf26e025ee5
|
4
|
+
data.tar.gz: feecfbdb093ff33ba2d589eb5058a6ffd3e4feeb621ee7b216d2d77c22f80829
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5b0aee349272bf73c9117c08f0a6b4e582e76f2adb80b0bd83a11708e6b8f3dfc2aef15bbd526250cc0a5942601297c1fc43e26397af77cf70c6f7489748e0c0
|
7
|
+
data.tar.gz: 66730f6912c6a4e1c4a7ba8e2e33d71aa2f535cf164a81c04124611dca637d056103cfc87368065e2fec95725adde4f5d66f3063101cbcfedcdefede4fbe1423
|
data/lib/testscore.rb
CHANGED
@@ -2,48 +2,46 @@ require 'json'
|
|
2
2
|
require 'zlib'
|
3
3
|
require 'net/http'
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
class
|
8
|
-
|
9
|
-
|
10
|
-
end
|
5
|
+
module ActiveRecord
|
6
|
+
class QueryCounter
|
7
|
+
class << self
|
8
|
+
attr_accessor :queries
|
9
|
+
end
|
11
10
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
end
|
11
|
+
IGNORED_SQL = [
|
12
|
+
/^PRAGMA (?!(table_info))/,
|
13
|
+
/^SELECT currval/,
|
14
|
+
/^SELECT CAST/,
|
15
|
+
/^SELECT @@IDENTITY/,
|
16
|
+
/^SELECT @@ROWCOUNT/,
|
17
|
+
/^SAVEPOINT/,
|
18
|
+
/FROM pg_attribute/,
|
19
|
+
/JOIN pg_attribute/,
|
20
|
+
/JOIN pg_namespace/,
|
21
|
+
/SHOW search_path/,
|
22
|
+
/^BEGIN$/,
|
23
|
+
/^ROLLBACK$/,
|
24
|
+
/^ROLLBACK TO SAVEPOINT/,
|
25
|
+
/^RELEASE SAVEPOINT/,
|
26
|
+
/^SHOW max_identifier_length/
|
27
|
+
]
|
28
|
+
|
29
|
+
def call(name, start, finish, message_id, values)
|
30
|
+
return if 'CACHE' == values[:name]
|
31
|
+
return if IGNORED_SQL.any? { |r| values[:sql] =~ r }
|
32
|
+
|
33
|
+
self.class.queries ||= []
|
34
|
+
self.class.queries << {
|
35
|
+
duration: finish - start,
|
36
|
+
sql: values[:sql]
|
37
|
+
}
|
40
38
|
end
|
41
39
|
end
|
42
40
|
end
|
43
41
|
|
44
42
|
module TestScore
|
45
43
|
def self.rails?
|
46
|
-
defined?(ActiveRecord) && defined?(ActiveSupport)
|
44
|
+
defined?(ActiveRecord) && defined?(ActiveSupport) && defined?(ActiveSupport::Notifications)
|
47
45
|
end
|
48
46
|
|
49
47
|
def self.queries
|