Class: Katello::Api::V2::HostDebsController
Constant Summary
Concerns::FilteredAutoCompleteSearch::PAGE_SIZE
Instance Method Summary
collapse
#auto_complete_search
#empty_search_query?, #full_result_response, #scoped_search, #skip_session
Methods included from Rendering
#respond_for_async, #respond_for_bulk_async, #respond_for_create, #respond_for_destroy, #respond_for_index, #respond_for_show, #respond_for_status, #respond_for_update, #respond_with_template, #respond_with_template_collection, #respond_with_template_resource, #try_specific_collection_template, #try_specific_resource_template
#api_version
Instance Method Details
#index ⇒ Object
33
34
35
36
37
|
# File 'app/controllers/katello/api/v2/host_debs_controller.rb', line 33
def index
collection = scoped_search(index_relation, :name, :asc, :resource_class => ::Katello::InstalledDeb)
collection[:results] = HostDebPresenter.with_latest(collection[:results], @host) if ::Foreman::Cast.to_bool(params[:include_latest_upgradable])
respond_for_index(:collection => collection)
end
|
#index_relation ⇒ Object
39
40
41
42
43
44
45
46
47
48
49
|
# File 'app/controllers/katello/api/v2/host_debs_controller.rb', line 39
def index_relation
packages = @host.installed_debs
upgradable_packages = ::Katello::Deb.installable_for_hosts([@host]).select(:name)
if params[:status].present?
packages = case params[:status]
when 'up-to-date' then packages.where.not(name: upgradable_packages)
when 'upgradable' then packages.where(name: upgradable_packages)
end
end
packages
end
|
#installed_debs ⇒ Object
15
16
17
18
19
20
21
22
23
24
25
|
# File 'app/controllers/katello/api/v2/host_debs_controller.rb', line 15
def installed_debs
_sort_by, _sort_order, options = sort_options
sort_by = 'name'
sort_order = 'asc'
options[:select] = "DISTINCT ON (#{::Katello::InstalledDeb.table_name}.name) #{::Katello::InstalledDeb.table_name}.id, #{::Katello::InstalledDeb.table_name}.name"
final_relation = ::Katello::InstalledDeb.all
result = scoped_search(final_relation, sort_by, sort_order, options)
respond_for_index(:collection => result, :template => "installed_debs")
end
|
#resource_class ⇒ Object
51
52
53
|
# File 'app/controllers/katello/api/v2/host_debs_controller.rb', line 51
def resource_class
Katello::InstalledDeb
end
|