Sha256: 4845e0035df4bd78c19a2c0b90e8d5a387aaf402006db5cf5aef356454e969ef

Contents?: true

Size: 901 Bytes

Versions: 13

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_filter :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

13 entries across 13 versions & 1 rubygems

Version Path
katello-3.1.0.1 app/controllers/katello/api/v2/packages_controller.rb
katello-3.1.0 app/controllers/katello/api/v2/packages_controller.rb
katello-3.1.0.rc2.1 app/controllers/katello/api/v2/packages_controller.rb
katello-3.0.2 app/controllers/katello/api/v2/packages_controller.rb
katello-3.1.0.rc1 app/controllers/katello/api/v2/packages_controller.rb
katello-3.0.1 app/controllers/katello/api/v2/packages_controller.rb
katello-3.0.0 app/controllers/katello/api/v2/packages_controller.rb
katello-3.0.0.rc7 app/controllers/katello/api/v2/packages_controller.rb
katello-3.0.0.rc5 app/controllers/katello/api/v2/packages_controller.rb
katello-3.0.0.rc4 app/controllers/katello/api/v2/packages_controller.rb
katello-3.0.0.rc3 app/controllers/katello/api/v2/packages_controller.rb
katello-3.0.0.rc2 app/controllers/katello/api/v2/packages_controller.rb
katello-3.0.0.rc1 app/controllers/katello/api/v2/packages_controller.rb