Class: AhoyCaptain::Filters::LocationsController

Inherits:
BaseController show all
Defined in:
app/controllers/ahoy_captain/filters/locations_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



4
5
6
7
8
# File 'app/controllers/ahoy_captain/filters/locations_controller.rb', line 4

def index
  query = visit_query.all

  render json: query.select("distinct #{params[:type]}").where.not(params[:type] => nil).group(params[:type]).order(Arel.sql "count(*) desc").limit(50).pluck(params[:type]).map { |city| serialize(city) }
end