Class: Trackguard::Admin::AnalyticsController

Inherits:
BaseController
  • Object
show all
Includes:
Overridable
Defined in:
app/controllers/trackguard/admin/analytics_controller.rb

Instance Method Summary collapse

Instance Method Details

#showObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/controllers/trackguard/admin/analytics_controller.rb', line 8

def show
  query = AnalyticsQuery.call(
    scope: page_view_scope,
    time_scope: apply_time_scope(page_view_scope),
    limit: 10
  )

  render json: {
    totals: query.totals,
    top_pages: query.top_pages,
    top_referrers: query.top_referrers,
    top_sources: query.top_sources,
    recent: visitor_filtered(apply_time_scope(query.recent)).map { |view| serialize_page_view(view) }
  }
end