Sha256: 0c2f5b8e72dff525ad37c5fbf12833707b3279bf0c525351f4ad9bee431b9412
Contents?: true
Size: 876 Bytes
Versions: 8
Compression:
Stored size: 876 Bytes
Contents
class ActiveRecord::Relation def calculate_with_jit(*args) if respond_to?(:proxy_association) && proxy_association.owner && proxy_association.owner.jit_n_plus_one_tracking ActiveSupport::Notifications.publish("n_plus_one_query", source: proxy_association.owner, association: "#{proxy_association.reflection.name}.#{args.first}") end calculate_without_jit(*args) end alias_method_chain :calculate, :jit def exec_queries_with_jit exec_queries_without_jit.tap do |records| if limit_value != 1 records.each{ |record| record.jit_n_plus_one_tracking = true } if jit_preload? || JitPreloader.globally_enabled? JitPreloader::Preloader.attach(records) end end end end alias_method_chain :exec_queries, :jit end
Version data entries
8 entries across 8 versions & 1 rubygems