Sha256: a8960f9bffba4727649c2f755671b61340b7a153bb67e18cbf550f278e404a62

Contents?: true

Size: 815 Bytes

Versions: 2

Compression:

Stored size: 815 Bytes

Contents

module InsightsCloud
  class HitsController < ::ApplicationController
    include Foreman::Controller::AutoCompleteSearch

    def index
      hits = resource_base_search_and_page.preload(:host)

      render json: {
        hasToken: Setting[:rh_cloud_token].length > 1,
        hits: hits.map { |hit| hit.attributes.merge(hostname: hit.host&.name) },
        itemCount: hits.count,
      }, status: :ok
    end

    def show
      host = Host.where(id: host_id_param).first

      render json: {
        hits: host.insights.hits,
      }, status: :ok
    end

    def model_of_controller
      ::InsightsHit
    end

    def resource_class
      ::InsightsHit
    end

    def controller_permission
      :insights_hits
    end

    private

    def host_id_param
      params.require(:host_id)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
foreman_rh_cloud-3.0.16 app/controllers/insights_cloud/hits_controller.rb
foreman_rh_cloud-3.0.15 app/controllers/insights_cloud/hits_controller.rb