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



229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
# File 'app/models/katello/concerns/host_managed_extensions.rb', line 229

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