debian-mirror-gitlab/lib/gitlab/query_limiting/active_support_subscriber.rb
2021-10-27 15:23:28 +05:30

16 lines
491 B
Ruby

# frozen_string_literal: true
module Gitlab
module QueryLimiting
class ActiveSupportSubscriber < ActiveSupport::Subscriber
attach_to :active_record
def sql(event)
return if !::Gitlab::QueryLimiting::Transaction.current || event.payload.fetch(:cached, event.payload[:name] == 'CACHE')
::Gitlab::QueryLimiting::Transaction.current.increment
::Gitlab::QueryLimiting::Transaction.current.executed_sql(event.payload[:sql])
end
end
end
end