Class: AhoyCaptain::SourceQuery
- Inherits:
-
ApplicationQuery
- Object
- ApplicationQuery
- AhoyCaptain::SourceQuery
- Defined in:
- app/queries/ahoy_captain/source_query.rb
Instance Attribute Summary
Attributes inherited from ApplicationQuery
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
#build ⇒ Object
3 4 5 6 7 8 |
# File 'app/queries/ahoy_captain/source_query.rb', line 3 def build visit_query.select("substring(referring_domain from '(?:.*://)?(?:www\.)?([^/?]*)') as referring_domain, count(substring(referring_domain from '(?:.*://)?(?:www\.)?([^/?]*)')) as count, sum(count(substring(referring_domain from '(?:.*://)?(?:www\.)?([^/?]*)'))) OVER() as total_count") .where.not(referring_domain: nil) .group("substring(referring_domain from '(?:.*://)?(?:www\.)?([^/?]*)')") .order(Arel.sql "count(substring(referring_domain from '(?:.*://)?(?:www\.)?([^/?]*)')) desc") end |