debian-mirror-gitlab/lib/gitlab/query_limiting/active_support_subscriber.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

17 lines
491 B
Ruby
Raw Normal View History

2019-02-15 15:39:39 +05:30
# frozen_string_literal: true
2018-03-17 18:26:18 +05:30
module Gitlab
module QueryLimiting
class ActiveSupportSubscriber < ActiveSupport::Subscriber
attach_to :active_record
2018-03-27 19:54:05 +05:30
def sql(event)
2021-10-27 15:23:28 +05:30
return if !::Gitlab::QueryLimiting::Transaction.current || event.payload.fetch(:cached, event.payload[:name] == 'CACHE')
2021-04-17 20:07:23 +05:30
2021-10-27 15:23:28 +05:30
::Gitlab::QueryLimiting::Transaction.current.increment
::Gitlab::QueryLimiting::Transaction.current.executed_sql(event.payload[:sql])
2018-03-17 18:26:18 +05:30
end
end
end
end