Module: Katello::Concerns::SubscriptionFacetHostExtensions::ClassMethods
- Defined in:
- app/models/katello/concerns/subscription_facet_host_extensions.rb
Instance Method Summary collapse
- #find_by_activation_key(_key, operator, value) ⇒ Object
- #find_by_activation_key_id(_key, operator, value) ⇒ Object
- #find_by_hypervisor_host(_key, operator, value) ⇒ Object
- #find_by_subscription_id(_key, operator, value) ⇒ Object
- #find_by_subscription_name(_key, operator, value) ⇒ Object
- #return_hosts(hosts) ⇒ Object
- #return_hosts_by_id(host_ids) ⇒ Object
- #rhel_lifecycle_status_map ⇒ Object
Instance Method Details
#find_by_activation_key(_key, operator, value) ⇒ Object
75 76 77 78 79 |
# File 'app/models/katello/concerns/subscription_facet_host_extensions.rb', line 75 def find_by_activation_key(_key, operator, value) conditions = sanitize_sql_for_conditions(["#{Katello::ActivationKey.table_name}.name #{operator} ?", value_to_sql(operator, value)]) hosts = ::Host::Managed.joins(:activation_keys).where(conditions) return_hosts(hosts) end |
#find_by_activation_key_id(_key, operator, value) ⇒ Object
81 82 83 84 85 |
# File 'app/models/katello/concerns/subscription_facet_host_extensions.rb', line 81 def find_by_activation_key_id(_key, operator, value) conditions = sanitize_sql_for_conditions(["#{Katello::ActivationKey.table_name}.id #{operator} ?", value_to_sql(operator, value)]) hosts = ::Host::Managed.joins(:activation_keys).where(conditions) return_hosts(hosts) end |
#find_by_hypervisor_host(_key, operator, value) ⇒ Object
87 88 89 90 91 92 |
# File 'app/models/katello/concerns/subscription_facet_host_extensions.rb', line 87 def find_by_hypervisor_host(_key, operator, value) conditions = sanitize_sql_for_conditions(["#{::Host.table_name}.name #{operator} ?", value_to_sql(operator, value)]) hosts = ::Host.where(conditions) hosts = ::Host.joins(:subscription_facet).where("#{Katello::Host::SubscriptionFacet.table_name}.hypervisor_host_id" => hosts) return_hosts(hosts) end |
#find_by_subscription_id(_key, operator, value) ⇒ Object
101 102 103 104 105 106 |
# File 'app/models/katello/concerns/subscription_facet_host_extensions.rb', line 101 def find_by_subscription_id(_key, operator, value) conditions = sanitize_sql_for_conditions(["#{Katello::Pool.table_name}.id #{operator} ?", value_to_sql(operator, value)]) sub_facets = ::Katello::Host::SubscriptionFacet.joins(:pools).where(conditions) host_ids = sub_facets.select(:host_id) return_hosts_by_id(host_ids) end |
#find_by_subscription_name(_key, operator, value) ⇒ Object
94 95 96 97 98 99 |
# File 'app/models/katello/concerns/subscription_facet_host_extensions.rb', line 94 def find_by_subscription_name(_key, operator, value) conditions = sanitize_sql_for_conditions(["#{Katello::Subscription.table_name}.name #{operator} ?", value_to_sql(operator, value)]) sub_facets = ::Katello::Host::SubscriptionFacet.joins(pools: :subscription).where(conditions) host_ids = sub_facets.select(:host_id) return_hosts_by_id(host_ids) end |
#return_hosts(hosts) ⇒ Object
116 117 118 119 120 121 122 |
# File 'app/models/katello/concerns/subscription_facet_host_extensions.rb', line 116 def return_hosts(hosts) if hosts.empty? {:conditions => "1=0"} else {:conditions => "#{::Host::Managed.table_name}.id IN (#{hosts.pluck(:id).join(',')})"} end end |
#return_hosts_by_id(host_ids) ⇒ Object
108 109 110 111 112 113 114 |
# File 'app/models/katello/concerns/subscription_facet_host_extensions.rb', line 108 def return_hosts_by_id(host_ids) if host_ids.empty? {:conditions => "1=0"} else {:conditions => "#{::Host::Managed.table_name}.id IN (#{host_ids.to_sql})"} end end |
#rhel_lifecycle_status_map ⇒ Object
71 72 73 |
# File 'app/models/katello/concerns/subscription_facet_host_extensions.rb', line 71 def rhel_lifecycle_status_map ::Katello::RhelLifecycleStatus.status_map end |