Class: AhoyCaptain::DashboardPresenter
Instance Attribute Summary collapse
Instance Method Summary
collapse
#comparison_mode, included
Methods included from Rangeable
#period
Constructor Details
Returns a new instance of DashboardPresenter.
9
10
11
|
# File 'app/presenters/ahoy_captain/dashboard_presenter.rb', line 9
def initialize(params)
@params = params
end
|
Instance Attribute Details
#params ⇒ Object
Returns the value of attribute params.
7
8
9
|
# File 'app/presenters/ahoy_captain/dashboard_presenter.rb', line 7
def params
@params
end
|
Instance Method Details
#bounce_rate ⇒ Object
29
30
31
32
33
34
35
36
|
# File 'app/presenters/ahoy_captain/dashboard_presenter.rb', line 29
def bounce_rate
query = Stats::BounceRatesQuery.call(params)
if compare_mode?
query.with_comparison(true)
else
query.average("bounce_rate").try(:round, 2) || 0
end
end
|
#total_pageviews ⇒ Object
21
22
23
|
# File 'app/presenters/ahoy_captain/dashboard_presenter.rb', line 21
def total_pageviews
Stats::TotalPageviewsQuery.call(params).with_comparison(compare_mode?).count
end
|
#total_visits ⇒ Object
17
18
19
|
# File 'app/presenters/ahoy_captain/dashboard_presenter.rb', line 17
def total_visits
Stats::TotalVisitorsQuery.call(params).with_comparison(compare_mode?).count
end
|
#unique_visitors ⇒ Object
13
14
15
|
# File 'app/presenters/ahoy_captain/dashboard_presenter.rb', line 13
def unique_visitors
Stats::UniqueVisitorsQuery.call(params).with_comparison(compare_mode?).count
end
|
#views_per_visit ⇒ Object
25
26
27
|
# File 'app/presenters/ahoy_captain/dashboard_presenter.rb', line 25
def views_per_visit
Stats::AverageViewsPerVisitQuery.call(params).with_comparison(compare_mode?).average("count")
end
|
#visit_duration ⇒ Object
38
39
40
41
42
43
44
45
|
# File 'app/presenters/ahoy_captain/dashboard_presenter.rb', line 38
def visit_duration
query = Stats::AverageVisitDurationQuery.call(params)
if compare_mode?
query.with_comparison(true)
else
query[0].average_visit_duration
end
end
|