Sha256: 94194c6ff4da0cc2679522f775c70ddb88e165590771fa8ad5d529e61ef1646b

Contents?: true

Size: 901 Bytes

Versions: 7

Compression:

Stored size: 901 Bytes

Contents

module Katello
  class Api::V2::PackagesController < Api::V2::ApiController
    apipie_concern_subst(:a_resource => N_("a package"), :resource => "packages")
    include Katello::Concerns::Api::V2::RepositoryContentController

    before_action :find_repositories, :only => :auto_complete_name

    def auto_complete_name
      page_size = Katello::Concerns::FilteredAutoCompleteSearch::PAGE_SIZE
      rpms = Rpm.in_repositories(@repositories)
      col = "#{Rpm.table_name}.name"
      rpms = rpms.where("#{Rpm.table_name}.name ILIKE ?", "#{params[:term]}%").select(col).group(col).order(col).limit(page_size)
      render :json => rpms.pluck(col)
    end

    def find_repositories
      @repositories = Repository.readable.where(:id => params[:repoids])
    end

    def resource_class
      Katello::Rpm
    end

    def default_sort
      lambda { |query| query.default_sort }
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
katello-3.2.1.1 app/controllers/katello/api/v2/packages_controller.rb
katello-3.2.1 app/controllers/katello/api/v2/packages_controller.rb
katello-3.2.0 app/controllers/katello/api/v2/packages_controller.rb
katello-3.2.0.rc3 app/controllers/katello/api/v2/packages_controller.rb
katello-3.2.0.rc2 app/controllers/katello/api/v2/packages_controller.rb
katello-3.2.0.rc1.1 app/controllers/katello/api/v2/packages_controller.rb
katello-3.2.0.rc1 app/controllers/katello/api/v2/packages_controller.rb