summaryrefslogtreecommitdiff
path: root/lib/gitlab/query_limiting/active_support_subscriber.rb
blob: 3c4ff5d19283dbcd93c370b0a41501da8e03899a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
module Gitlab
  module QueryLimiting
    class ActiveSupportSubscriber < ActiveSupport::Subscriber
      attach_to :active_record

      def sql(event)
        unless event.payload.fetch(:cached, event.payload[:name] == 'CACHE')
          Transaction.current&.increment
        end
      end
    end
  end
end