Class: AhoyCaptain::Stats::VisitDurationQuery
- Inherits:
-
BaseQuery
- Object
- ApplicationQuery
- BaseQuery
- AhoyCaptain::Stats::VisitDurationQuery
- Defined in:
- app/queries/ahoy_captain/stats/visit_duration_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 |
# File 'app/queries/ahoy_captain/stats/visit_duration_query.rb', line 4 def build events = event_query .reselect("max(#{AhoyCaptain.event.table_name}.time) - min(#{AhoyCaptain.event.table_name}.time) as duration, #{AhoyCaptain.event.table_name}.visit_id") .group("#{AhoyCaptain.event.table_name}.visit_id") ::Ahoy::Visit .select("duration::duration as duration, started_at") .from(events, :views_per_visit_table) .joins("inner join #{AhoyCaptain.visit.table_name} on #{AhoyCaptain.visit.table_name}.id = views_per_visit_table.visit_id") end |