Project

General

Profile

« Previous | Next » 

Revision 88275be4

Added by Tom Caspy over 8 years ago

fixes #10589 - removing N+1 queries from after_save callbacks when changing hostgroup

View differences:

app/models/puppetclass.rb
hgs
end
def all_hosts
def all_host_ids
ids = host_ids
ids += all_hostgroups.flat_map(&:host_ids)
ids += Host::Managed.unscoped.where(:hostgroup_id => all_hostgroups.map(&:id)).pluck(:id)
ids += host_ids_from_config_groups('Host::Base')
Host::Managed.unscoped.where(:id => ids.uniq)
ids.uniq
end
def update_total_hosts
update_attribute(:total_hosts, all_hosts.count)
update_attribute(:total_hosts, all_host_ids.size)
end
# Populates the rdoc tree with information about all the classes in your modules.

Also available in: Unified diff