Class: Katello::Api::V2::ErrataController
- Inherits:
-
ApiController
- Object
- Api::V2::BaseController
- ApiController
- Katello::Api::V2::ErrataController
show all
- Includes:
- Concerns::Api::V2::RepositoryContentController
- Defined in:
- app/controllers/katello/api/v2/errata_controller.rb
Instance Method Summary
collapse
#empty_search_query?, #full_result_response, #resource_class, #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
#all_for_content_view_filter(filter, _collection) ⇒ Object
39
40
41
42
43
|
# File 'app/controllers/katello/api/v2/errata_controller.rb', line 39
def all_for_content_view_filter(filter, _collection)
available_ids = Erratum.joins(:repositories).merge(filter.applicable_repos)&.pluck(:errata_id) || []
added_ids = filter&.erratum_rules&.pluck(:errata_id) || []
Erratum.where(errata_id: available_ids + added_ids)
end
|
#available_for_content_view_filter(filter, collection) ⇒ Object
32
33
34
35
36
37
|
# File 'app/controllers/katello/api/v2/errata_controller.rb', line 32
def available_for_content_view_filter(filter, collection)
collection = filter_by_content_view(filter, collection)
ids = Katello::ContentViewErratumFilterRule.where(:content_view_filter_id => filter.id).pluck("errata_id")
collection = collection.where("errata_id not in (?)", ids) unless ids.empty?
collection
end
|
#available_for_content_view_version(version) ⇒ Object
28
29
30
|
# File 'app/controllers/katello/api/v2/errata_controller.rb', line 28
def available_for_content_view_version(version)
version.available_errata
end
|
#custom_index_relation(collection) ⇒ Object
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
# File 'app/controllers/katello/api/v2/errata_controller.rb', line 45
def custom_index_relation(collection)
collection = filter_by_cve(params[:cve], collection) if params[:cve]
applicable = ::Foreman::Cast.to_bool(params[:errata_restrict_applicable]) || @host
installable = ::Foreman::Cast.to_bool(params[:errata_restrict_installable])
if applicable || installable
hosts = @host ? ::Host::Managed.where(:id => @host.id) : ::Host::Managed.authorized("view_hosts")
hosts = hosts.where(:organization_id => params[:organization_id]) if params[:organization_id]
if installable
collection = collection.where(:id => Erratum.ids_installable_for_hosts(hosts))
elsif applicable
collection = collection.applicable_to_hosts(hosts)
end
end
@date_type = params[:date_type].present? ? params[:date_type] : ContentViewErratumFilterRule::UPDATED
unless ContentViewErratumFilterRule::DATE_TYPES.include?(@date_type)
msg = _("Invalid params provided - date_type must be one of %s" % ContentViewErratumFilterRule::DATE_TYPES.join(","))
fail HttpErrors::UnprocessableEntity, msg
end
custom_index_relation_handle_type_and_time(collection)
end
|
#custom_index_relation_handle_type_and_time(collection) ⇒ Object
67
68
69
70
71
72
73
74
75
76
77
78
79
|
# File 'app/controllers/katello/api/v2/errata_controller.rb', line 67
def custom_index_relation_handle_type_and_time(collection)
collection = collection.where("#{@date_type} >= ?", params[:start_date]) if params[:start_date]
collection = collection.where("#{@date_type} <= ?", params[:end_date]) if params[:end_date]
if params[:types]
include_other = params[:types]&.include?('other')
params[:types]&.delete('other')
collection = collection.of_type(
params[:types],
include_other
)
end
collection
end
|
#index ⇒ Object
24
25
26
|
# File 'app/controllers/katello/api/v2/errata_controller.rb', line 24
def index
super
end
|