b0VIM 9.0#9ädRð) satoshiN-251~satoshi/src/activerecord-transaction_subscriber/lib/activerecord/transaction_subscriber.rb 3210#"! UtpKad× Kâᯮš^65"ãâÈÇ­”ƒa+ æ Ö £ • ˆ h \ ; + þ ð Ñ ¿ £ | n b X P O 7  ç ¥ c ) î È • ‹ d \ [ E 6  ö Ü Ì ² ¢ ˆ x ^ N C 7 - %    end end end end nil else :delete when /\A\s*delete/i :update when /\A\s*update/i :insert when /\A\s*insert/i :select when /\A\s*select/i :lock when /select .*for update/mi, /\A\s*lock/mi case sql def sql_type(sql) end info color(text, :magenta, true) end text << ", #{type}: #{count} (#{total}ms)" total = tx[type].sum.round(1) count = tx[type].size next unless tx[type] %i[lock select insert update delete].each do |type| text = " Transaction #{name} real time: #{elapsed_time}ms" elapsed_time = ((end_at - tx[:start_at]) * 1000.0).round(1) def logging(name, tx, end_at) end self.class.transactions ||= [] def my_transactions end end end end tx[type] << event.duration tx[type] ||= [] if type type = sql_type(sql) if tx tx = my_transactions.last else # no-op when *IGNORE_PAYLOAD_NAMES end # Unknown transaction else end logging(payload[:name], tx, event.end) if tx tx = my_transactions.pop when 'COMMIT', 'ROLLBACK' my_transactions << { start_at: event.time } when 'BEGIN', 'SAVEPOINT' case sql when 'TRANSACTION' case payload[:name] sql = payload[:sql] return if payload[:cached] payload = event.payload def sql(event) thread_mattr_accessor :transactions class TransactionSubscriber < ActiveRecord::LogSubscribermodule ActiveRecordrequire_relative "transaction_subscriber/version"# frozen_string_literal: true