Class: AhoyCaptain::Stats::ViewsPerVisitQuery
- Inherits:
-
BaseQuery
- Object
- ApplicationQuery
- BaseQuery
- AhoyCaptain::Stats::ViewsPerVisitQuery
- Defined in:
- app/queries/ahoy_captain/stats/views_per_visit_query.rb
Instance Attribute Summary
Attributes inherited from ApplicationQuery
Instance Method Summary collapse
Methods included from LazyComparableQuery
Methods included from ComparableQuery
Methods inherited from ApplicationQuery
call, inherited, #initialize, #inspect
Constructor Details
This class inherits a constructor from AhoyCaptain::ApplicationQuery
Instance Method Details
#build ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 |
# File 'app/queries/ahoy_captain/stats/views_per_visit_query.rb', line 4 def build events = event_query .joins(:visit) .select("#{::AhoyCaptain.visit.table_name}.started_at as started_at, count(#{AhoyCaptain.event.table_name}.name) / count(distinct #{AhoyCaptain.event.table_name}.visit_id) as views_per_visit") .where(name: AhoyCaptain.config.event[:view_name]) .group("#{AhoyCaptain.visit.table_name}.started_at, #{AhoyCaptain.event.table_name}.visit_id") ::Ahoy::Visit .select("views_per_visit as views_per_visit") .from(events, :views_per_visit_table) end |