app/controllers/katello/api/v2/errata_controller.rb in katello-4.2.2 vs app/controllers/katello/api/v2/errata_controller.rb in katello-4.3.0.rc1

- old
+ new

@@ -29,23 +29,17 @@ 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? - - 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 - - collection = collection.where("#{date_type} >= ?", params[:start_date]) if params[:start_date] - collection = collection.where("#{date_type} <= ?", params[:end_date]) if params[:end_date] - collection = collection.of_type(params[:types]) if params[:types] collection end + def all_for_content_view_filter(filter, _collection) + Erratum.joins(:repositories).merge(filter.applicable_repos) + end + 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 @@ -55,9 +49,18 @@ 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 + + collection = collection.where("#{date_type} >= ?", params[:start_date]) if params[:start_date] + collection = collection.where("#{date_type} <= ?", params[:end_date]) if params[:end_date] + collection = collection.of_type(params[:types]) if params[:types] collection end private