Module: Katello::Concerns::HostManagedExtensions::ClassMethods

Defined in:
app/models/katello/concerns/host_managed_extensions.rb

Instance Method Summary collapse

Instance Method Details

#find_by_installed_debs(_key, _operator, value) ⇒ Object



188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
# File 'app/models/katello/concerns/host_managed_extensions.rb', line 188

def find_by_installed_debs(_key, _operator, value)
  name, architecture, version = Katello::Deb.split_nav(value)
  debs = Katello::InstalledDeb.where(:name => name)
  debs = debs.where(:architecture => architecture) unless architecture.nil?
  debs = debs.where(:version => version) unless version.nil?
  hosts = debs.joins(:host_installed_debs).select("#{Katello::HostInstalledDeb.table_name}.host_id as host_id").pluck(:host_id)
  if hosts.empty?
    {
      :conditions => "1=0",
    }
  else
    {
      :conditions => "#{::Host::Managed.table_name}.id IN (#{hosts.join(',')})",
    }
  end
end