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
- #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
69 70 71 72 73 |
# File 'app/models/katello/concerns/subscription_facet_host_extensions.rb', line 69 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
75 76 77 78 79 |
# File 'app/models/katello/concerns/subscription_facet_host_extensions.rb', line 75 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
81 82 83 84 85 86 |
# File 'app/models/katello/concerns/subscription_facet_host_extensions.rb', line 81 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 |
#return_hosts(hosts) ⇒ Object
96 97 98 99 100 101 102 |
# File 'app/models/katello/concerns/subscription_facet_host_extensions.rb', line 96 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
88 89 90 91 92 93 94 |
# File 'app/models/katello/concerns/subscription_facet_host_extensions.rb', line 88 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
65 66 67 |
# File 'app/models/katello/concerns/subscription_facet_host_extensions.rb', line 65 def rhel_lifecycle_status_map ::Katello::RhelLifecycleStatus.status_map end |