Class: AhoyCaptain::Filters::Properties::ValuesController

Inherits:
BaseController show all
Defined in:
app/controllers/ahoy_captain/filters/properties/values_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#period

Methods included from Rangeable

#period

Methods included from CompareMode

#compare_mode?, #comparison_mode, included

Instance Method Details

#indexObject



5
6
7
8
9
10
11
# File 'app/controllers/ahoy_captain/filters/properties/values_controller.rb', line 5

def index
  param_key = params[:q].to_unsafe_h.detect { |k,v| k.ends_with?("_i_cont") && k.starts_with?("properties.") }[0]
  key = param_key.delete_prefix("properties.").delete_suffix("_i_cont")
  query = event_query.all.distinct.select("properties->>'#{key}'").pluck(Arel.sql "properties->>'#{key}'")

  render json: query.map { |element| serialize(element) }
end