Class: AhoyCaptain::CityQuery

Inherits:
ApplicationQuery show all
Defined in:
app/queries/ahoy_captain/city_query.rb

Instance Attribute Summary

Attributes inherited from ApplicationQuery

#params

Instance Method Summary collapse

Methods inherited from ApplicationQuery

call, inherited, #initialize, #inspect

Constructor Details

This class inherits a constructor from AhoyCaptain::ApplicationQuery

Instance Method Details

#buildObject



3
4
5
6
7
8
9
# File 'app/queries/ahoy_captain/city_query.rb', line 3

def build
  visit_query
    .select("city, country, count(concat(city, region, country)) as count, sum(count(concat(city, region, country))) over() as total_count")
    .where.not(city: nil)
    .group("city, region, country")
    .order(Arel.sql "count(concat(city, region, country)) desc")
end