-
Notifications
You must be signed in to change notification settings - Fork 898
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use a single query to get count of active VMs and Hosts #19835
Use a single query to get count of active VMs and Hosts #19835
Conversation
Instead of looping through all ExtManagementSystems and adding up the counts of vms and hosts manually we can get this count in one shot by querying for active VMs and Hosts.
17b393e
to
2f83c8f
Compare
@@ -143,6 +143,9 @@ class Host < ApplicationRecord | |||
virtual_total :v_total_vms, :vms | |||
virtual_total :v_total_miq_templates, :miq_templates | |||
|
|||
scope :active, -> { where.not(:ems_id => nil) } | |||
scope :archived, -> { where(:ems_id => nil) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are handy scopes to have, only the active
scope here is used but both are generally helpful
Checked commit agrare@2f83c8f with ruby 2.5.7, rubocop 0.69.0, haml-lint 0.20.0, and yamllint |
/cc @jaredm-ibm |
LGTM - will merge when tests are green |
…_performance Use a single query to get count of active VMs and Hosts (cherry picked from commit cee35bf) https://bugzilla.redhat.com/show_bug.cgi?id=1805915
Ivanchuk backport details:
|
Instead of looping through all ExtManagementSystems and adding up the counts of vms and hosts manually we can get this count in one shot by querying for active VMs and Hosts.
Follow-up for #19830