foreman/app/controllers/facts_controller.rb @ 9d43fc71
b96931f2 | Ohad Levy | class FactsController < ApplicationController
|
|
df6a9f34 | Dominic Cleal | before_action :valid_request?
|
|
b96931f2 | Ohad Levy | ||
def index
|
|||
5d264a2d | Ohad Levy | render :json => FactName.no_timestamp_fact
|
|
b96931f2 | Ohad Levy | end
|
|
ee878ae8 | Ohad Levy | def show
|
|
@fact = FactName.find(params[:id])
|
|||
begin
|
|||
81e40e3a | Tomer Brisker | data = {:name => CGI.escapeHTML(@fact.name),
|
|
9d43fc71 | Michael Moll | :values => FactValue.count_each(@fact.name).to_a.each{|v| v[:label] = CGI.escapeHTML(v[:label])}}
|
|
ee878ae8 | Ohad Levy | rescue
|
|
data = @fact
|
|||
end
|
|||
b4da3d90 | lizagilman | data[:values].map!(&:values)
|
|
ee878ae8 | Ohad Levy | render :json => data
|
|
end
|
|||
private
|
|||
# we currently only support JSON in this controller
|
|||
def valid_request?
|
|||
67799065 | Ohad Levy | not_found unless api_request?
|
|
ee878ae8 | Ohad Levy | end
|
|
b96931f2 | Ohad Levy | end
|