Class: AhoyCaptain::TopPageQuery

Inherits:
ApplicationQuery show all
Defined in:
app/queries/ahoy_captain/top_page_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
10
11
# File 'app/queries/ahoy_captain/top_page_query.rb', line 3

def build
  event_query.with_routes
             .select(
    "#{AhoyCaptain.config.event[:url_column]} as url",
    "count(*) as count",
    "sum(count(*)) over() as total_count"
  ).group(Arel.sql ("(#{AhoyCaptain.config.event[:url_column]})"))
             .order(Arel.sql("count(#{AhoyCaptain.config.event[:url_column]}) desc"))
end