lib/wt_activerecord_index_spy/notification_listener.rb
# TODO: refactor me pls to remove all these Rubocop warnings!
# rubocop:disable Metrics/AbcSize
# rubocop:disable Metrics/MethodLength
refactor me pls to remove all these Rubocop warnings.
refactor me pls to remove all these Rubocop warnings .
def call(_name, _start, _finish, _message_id, values)
      query = values[:sql]
      logger.debug "query: #{query}"
      identifier = values[:name].to_s
      if ignore_query?(query: query, name: identifier)
        logger.debug "query type ignored, name: #{identifier}, query: #{query}"
        return
      end
      logger.debug "query type accepted"
      origin = caller.find { |line| !line.include?("/gems/") }
      if @ignore_queries_originated_in_test_code && query_originated_in_tests?(origin)
        logger.debug "origin ignored: #{origin}"
        return
      end
      logger.debug "origin accepted: #{origin}"
      certainity_level = @query_analyser.analyse(**values.slice(:sql, :connection, :binds))
      return unless certainity_level
      item = Aggregator::Item.new(
        identifier: identifier,
        query: query,
        origin: reduce_origin(origin),
        certainity_level: certainity_level
      )
      @aggregator.add(item)
    end
def call ( _name , _start , _finish , _message_id , values ) query = values [ :sql ] logger . debug "query: #{query}" identifier = values [ :name ] . to_s if ignore_query? ( query : query , name : identifier ) logger . debug "query type ignored, name: #{identifier}, query: #{query}" return end logger . debug "query type accepted" origin = caller . find { | line | ! line . include? ( "/gems/" ) } if @ignore_queries_originated_in_test_code && query_originated_in_tests? ( origin ) logger . debug "origin ignored: #{origin}" return end logger . debug "origin accepted: #{origin}" certainity_level = @query_analyser . analyse ( ** values . slice ( :sql , :connection , :binds ) ) return unless certainity_level item = Aggregator :: Item . new ( identifier : identifier , query : query , origin : reduce_origin ( origin ) , certainity_level : certainity_level ) @aggregator . add ( item ) end
TODO: refactor me pls to remove all these Rubocop warnings!
TODO : refactor me pls to remove all these Rubocop warnings!
# Hopefully, it will get the line which executed the query. # It ignores activerecord, activesupport and other gem frames. # Maybe there is a better way to achieve it
_name
<not_specific>
_start
<not_specific>
_finish
<not_specific>
_message_id
<not_specific>
values
<not_specific>