Sha256: dee0effe085b206d0ef75b4a20c489bba4e6c933d030253be5baf25299cb49ac
Contents?: true
Size: 1.32 KB
Versions: 13
Compression:
Stored size: 1.32 KB
Contents
module Katello module Concerns module Api::V2::HostErrataExtensions extend ActiveSupport::Concern def find_bulk_errata_ids(hosts, bulk_errata_ids) bulk_params = ActiveSupport::JSON.decode(bulk_errata_ids).deep_symbolize_keys bulk_params[:included] ||= {} bulk_params[:excluded] ||= {} if bulk_params[:included][:ids].blank? && bulk_params[:included][:search].nil? fail HttpErrors::BadRequest, _("No errata has been specified.") end #works on a structure of param_group bulk_params and transforms it into a list of errata_ids errata = ::Katello::Erratum.installable_for_hosts(hosts) if bulk_params[:included][:ids] errata = errata.where(:errata_id => bulk_params[:included][:ids]) end if bulk_params[:included][:search] search_errata = ::Katello::Erratum.installable_for_hosts(hosts) search_errata = search_errata.search_for(bulk_params[:included][:search]) if errata.any? errata = errata.merge(search_errata) else errata = search_errata end end if bulk_params[:excluded][:ids].present? errata = errata.where.not(errata_id: bulk_params[:excluded][:ids]) end errata.pluck(:errata_id) end end end end
Version data entries
13 entries across 13 versions & 1 rubygems