class Bullet::Detector::UnusedEagerLoading

def check_unused_preload_associations

if association not in call_object_association, then the object => association - call_object_association is ununsed preload associations
get call_object_association from associations of call_object_associations whose object is in related_objects
get related_objects from eager_loadings associated with object and associations
check if there are unused preload associations.
def check_unused_preload_associations
  return unless Bullet.start?
  return unless Bullet.unused_eager_loading_enable?
  object_associations.each do |bullet_key, associations|
    object_association_diff = diff_object_associations bullet_key, associations
    next if object_association_diff.empty?
    Bullet.debug('detect unused preload', "object: #{bullet_key}, associations: #{object_association_diff}")
    create_notification(caller_in_project(bullet_key), bullet_key.bullet_class_name, object_association_diff)
  end
end