Sha256: 168057a3d865e1436da145331c4bfc3f5d464e6e1966a0f652bbde0417d7c16a

Contents?: true

Size: 903 Bytes

Versions: 49

Compression:

Stored size: 903 Bytes

Contents

module Katello
  class BulkItemsHelper
    attr_reader :bulk_params, :model_scope, :key

    def initialize(bulk_params:, model_scope:, key: :id)
      @bulk_params = bulk_params

      if @bulk_params.is_a?(String)
        @bulk_params = ActiveSupport::JSON.decode(@bulk_params).
                      deep_symbolize_keys
      end

      @model_scope = model_scope
      @key = key
    end

    def fetch
      params = bulk_params
      params[:included] ||= {}
      params[:excluded] ||= {}

      items = model_scope
      if params[:included][:ids].present?
        items = model_scope.where(key => params[:included][:ids])
      elsif params[:included][:search].present?
        items = model_scope.search_for(params[:included][:search])
      end
      if params[:excluded][:ids].present?
        items = items.where.not(key => params[:excluded][:ids])
      end

      items
    end
  end
end

Version data entries

49 entries across 49 versions & 1 rubygems

Version Path
katello-4.14.2 app/services/katello/bulk_items_helper.rb
katello-4.15.0 app/services/katello/bulk_items_helper.rb
katello-4.15.0.rc2 app/services/katello/bulk_items_helper.rb
katello-4.15.0.rc1 app/services/katello/bulk_items_helper.rb
katello-4.14.1 app/services/katello/bulk_items_helper.rb
katello-4.14.0 app/services/katello/bulk_items_helper.rb
katello-4.14.0.rc3 app/services/katello/bulk_items_helper.rb
katello-4.14.0.rc2 app/services/katello/bulk_items_helper.rb
katello-4.14.0.rc1.1 app/services/katello/bulk_items_helper.rb
katello-4.14.0.rc1 app/services/katello/bulk_items_helper.rb
katello-4.13.1 app/services/katello/bulk_items_helper.rb
katello-4.13.0 app/services/katello/bulk_items_helper.rb
katello-4.12.1 app/services/katello/bulk_items_helper.rb
katello-4.13.0.rc1 app/services/katello/bulk_items_helper.rb
katello-4.12.0 app/services/katello/bulk_items_helper.rb
katello-4.12.0.rc3 app/services/katello/bulk_items_helper.rb
katello-4.12.0.rc2 app/services/katello/bulk_items_helper.rb
katello-4.12.0.rc1 app/services/katello/bulk_items_helper.rb
katello-4.11.1 app/services/katello/bulk_items_helper.rb
katello-4.11.0 app/services/katello/bulk_items_helper.rb