time_bandits 0.13.1 → 0.14.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/run-tests.yml +1 -1
- data/Appraisals +4 -3
- data/CHANGELOG.md +4 -0
- data/Gemfile +0 -3
- data/docker-compose.yml +1 -1
- data/lib/time_bandits/monkey_patches/active_record.rb +63 -10
- data/lib/time_bandits/version.rb +1 -1
- data/test/test_helper.rb +1 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d5b75c63570dfa36709209cb0e1abe7fd8842bc795c7e0c5dd15a285af090bf6
|
4
|
+
data.tar.gz: afb24d0ea48efe0ec1505be1550ece1cb31af9c4b1eb5df55b96e2c1898e90b4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 05a7d021d2b0242a5289450fa385dc86d6c3e2512c4a331e40a3428d7d5ab19be347544a32bac8df2a1ba726c898a6ba8b51a698312107a5a7730995a45cfacd
|
7
|
+
data.tar.gz: 953e21a301535b9384263fd1d686e5dd4eea45ca25bd5b64191f979b6b83dde73e439f38428114e54e6ee83ce7baffc2fa16e7c492cabd070a0dcb29b409a4e3
|
data/Appraisals
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
appraisals = [
|
2
|
-
"6.0.6",
|
3
|
-
"6.1.6",
|
2
|
+
"6.0.6.1",
|
3
|
+
"6.1.7.6",
|
4
|
+
"7.0.8",
|
5
|
+
"7.1.0"
|
4
6
|
]
|
5
7
|
|
6
8
|
appraisals.insert(0, "5.2.8.1") if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("3.0.0")
|
7
|
-
appraisals << "7.0.4" if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("2.7.0")
|
8
9
|
|
9
10
|
appraisals.each do |rails_version|
|
10
11
|
%w(4.0 5.0).each do |redis_version|
|
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
data/docker-compose.yml
CHANGED
@@ -9,6 +9,18 @@ module ActiveRecord
|
|
9
9
|
class LogSubscriber
|
10
10
|
IGNORE_PAYLOAD_NAMES = ["SCHEMA", "EXPLAIN"] unless defined?(IGNORE_PAYLOAD_NAMES)
|
11
11
|
|
12
|
+
if Gem::Version.new(ActiveRecord::VERSION::STRING) >= Gem::Version.new("7.1.0")
|
13
|
+
def self.reset_runtime
|
14
|
+
ActiveRecord::RuntimeRegistry.reset
|
15
|
+
end
|
16
|
+
def self.runtime
|
17
|
+
ActiveRecord::RuntimeRegistry.sql_runtime
|
18
|
+
end
|
19
|
+
def self.runtime=(value)
|
20
|
+
ActiveRecord::RuntimeRegistry.sql_runtime = value
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
12
24
|
def self.call_count=(value)
|
13
25
|
Thread.current.thread_variable_set(:active_record_sql_call_count, value)
|
14
26
|
end
|
@@ -56,23 +68,64 @@ module ActiveRecord
|
|
56
68
|
|
57
69
|
private
|
58
70
|
def log_sql_statement(payload, event)
|
59
|
-
name
|
71
|
+
name = if payload[:async]
|
72
|
+
"ASYNC #{payload[:name]} (#{payload[:lock_wait].round(1)}ms) (db time #{event.duration.round(1)}ms)"
|
73
|
+
else
|
74
|
+
"#{payload[:name]} (#{event.duration.round(1)}ms)"
|
75
|
+
end
|
60
76
|
name = "CACHE #{name}" if payload[:cached]
|
61
77
|
sql = payload[:sql]
|
62
|
-
binds =
|
63
|
-
|
64
|
-
unless (payload[:binds] || []).empty?
|
65
|
-
casted_params = type_casted_binds(payload[:type_casted_binds])
|
66
|
-
binds = " " + payload[:binds].zip(casted_params).map { |attr, value|
|
67
|
-
render_bind(attr, value)
|
68
|
-
}.inspect
|
69
|
-
end
|
78
|
+
binds = render_binds(payload)
|
70
79
|
|
71
80
|
name = colorize_payload_name(name, payload[:name])
|
72
|
-
sql =
|
81
|
+
sql = colorize_sql(sql) if colorize_logging
|
73
82
|
|
74
83
|
debug " #{name} #{sql}#{binds}"
|
75
84
|
end
|
85
|
+
|
86
|
+
if Gem::Version.new(ActiveRecord::VERSION::STRING) >= Gem::Version.new("7.1.0")
|
87
|
+
def render_binds(payload)
|
88
|
+
binds = nil
|
89
|
+
if payload[:binds]&.any?
|
90
|
+
casted_params = type_casted_binds(payload[:type_casted_binds])
|
91
|
+
|
92
|
+
binds = []
|
93
|
+
payload[:binds].each_with_index do |attr, i|
|
94
|
+
attribute_name = if attr.respond_to?(:name)
|
95
|
+
attr.name
|
96
|
+
elsif attr.respond_to?(:[]) && attr[i].respond_to?(:name)
|
97
|
+
attr[i].name
|
98
|
+
else
|
99
|
+
nil
|
100
|
+
end
|
101
|
+
|
102
|
+
filtered_params = filter(attribute_name, casted_params[i])
|
103
|
+
|
104
|
+
binds << render_bind(attr, filtered_params)
|
105
|
+
end
|
106
|
+
binds = binds.inspect
|
107
|
+
binds.prepend(" ")
|
108
|
+
end
|
109
|
+
return binds
|
110
|
+
end
|
111
|
+
def colorize_sql(sql)
|
112
|
+
color(sql, sql_color(sql), bold: true)
|
113
|
+
end
|
114
|
+
else
|
115
|
+
def render_binds(payload)
|
116
|
+
binds = nil
|
117
|
+
unless (payload[:binds] || []).empty?
|
118
|
+
casted_params = type_casted_binds(payload[:type_casted_binds])
|
119
|
+
binds = " " + payload[:binds].zip(casted_params).map { |attr, value|
|
120
|
+
render_bind(attr, value)
|
121
|
+
}.inspect
|
122
|
+
end
|
123
|
+
return binds
|
124
|
+
end
|
125
|
+
def colorize_sql(sql)
|
126
|
+
color(sql, sql_color(sql), true)
|
127
|
+
end
|
128
|
+
end
|
76
129
|
end
|
77
130
|
|
78
131
|
require "active_record/railties/controller_runtime"
|
data/lib/time_bandits/version.rb
CHANGED
data/test/test_helper.rb
CHANGED
@@ -23,6 +23,7 @@ ActiveSupport::LogSubscriber.logger =::Logger.new("/dev/null")
|
|
23
23
|
# fake Rails
|
24
24
|
module Rails
|
25
25
|
extend self
|
26
|
+
ActiveSupport::Cache.format_version = 7.1 if Gem::Version.new(ActiveSupport::VERSION::STRING) >= Gem::Version.new("7.1.0")
|
26
27
|
def cache
|
27
28
|
@cache ||= ActiveSupport::Cache.lookup_store(:mem_cache_store)
|
28
29
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: time_bandits
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.14.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stefan Kaes
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-10-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thread_variables
|
@@ -289,7 +289,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
289
289
|
- !ruby/object:Gem::Version
|
290
290
|
version: '0'
|
291
291
|
requirements: []
|
292
|
-
rubygems_version: 3.4.
|
292
|
+
rubygems_version: 3.4.10
|
293
293
|
signing_key:
|
294
294
|
specification_version: 4
|
295
295
|
summary: Custom performance logging for Rails
|