N+1 Query when changing hostgroup from the "All Hosts" page
I believe there is a N+1 query when modifying a single host or multiple hosts from the "All Hosts" page of the Foreman. Changing a hostgroup from this page is taking ~5-8 minutes to complete depending on the number of hosts being modified.
Found by loading foreman-rake console
hg = Hostgroup.find_by_id(1)
h = Host.find_by_name("name of host")
h.save(:validate => false)
I've attached the specific query that I believe has the N+1. It is executed several times in this block of code which I think is the reason the host group change takes such a long time to complete.
fixes #10589 - removing N+1 queries from after_save callbacks when changing hostgroup