5
6
7
8
9
10
11
12
13
14
15
16
17
|
# File 'lib/spree/manipulative_query_monitor.rb', line 5
def self.call(&block)
counter = ::DBQueryMatchers::QueryCounter.new({matches: [/^\ *(INSERT|UPDATE|DELETE\ FROM)/]})
ActiveSupport::Notifications.subscribed(counter.to_proc,
"sql.active_record",
&block)
if counter.count > 0
message = "Detected #{counter.count} manipulative queries. #{counter.log.join(", ")}\n"
message += caller.select { |line| line.include?(Rails.root.to_s) || line.include?("solidus") }.join("\n")
Rails.logger.warn(message)
end
end
|