Module: Spotlight::ExhibitAnalytics

Included in:
Exhibit
Defined in:
app/models/concerns/spotlight/exhibit_analytics.rb

Overview

Exhibit mixin to provide analytics data

Instance Method Summary collapse

Instance Method Details

#analytics(dates = { start_date: '365daysAgo', end_date: 'today' }, path = nil) ⇒ Object



7
8
9
10
11
12
13
# File 'app/models/concerns/spotlight/exhibit_analytics.rb', line 7

def analytics(dates = { start_date: '365daysAgo', end_date: 'today' }, path = nil)
  return OpenStruct.new unless analytics_provider&.enabled?

  @analytics ||= {}
  start_date = dates['start_date'] || 1.month.ago
  @analytics[start_date] ||= analytics_provider.exhibit_data(path || self, dates)
end

#analytics_providerObject



23
24
25
# File 'app/models/concerns/spotlight/exhibit_analytics.rb', line 23

def analytics_provider
  @analytics_provider ||= Spotlight::Engine.config.analytics_provider.new
end

#page_analytics(dates = { start_date: '365daysAgo', end_date: 'today' }, path = nil) ⇒ Object



15
16
17
18
19
20
21
# File 'app/models/concerns/spotlight/exhibit_analytics.rb', line 15

def page_analytics(dates = { start_date: '365daysAgo', end_date: 'today' }, path = nil)
  return [] unless analytics_provider&.enabled?

  @page_analytics ||= {}
  start_date = dates['start_date'] || 1.month.ago
  @page_analytics[start_date] ||= analytics_provider.page_data(path || self, dates)
end