Class: Spotlight::Analytics::DashboardComponent

Inherits:
ViewComponent::Base
  • Object
show all
Defined in:
app/components/spotlight/analytics/dashboard_component.rb

Overview

Display Analytics

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(current_exhibit:) ⇒ DashboardComponent

Returns a new instance of DashboardComponent.



9
10
11
12
13
# File 'app/components/spotlight/analytics/dashboard_component.rb', line 9

def initialize(current_exhibit:)
  super
  @current_exhibit = current_exhibit
  @dates = { 'start_date' => '365daysAgo', 'end_date' => 'today' }
end

Instance Attribute Details

#current_exhibitObject (readonly)

Returns the value of attribute current_exhibit.



7
8
9
# File 'app/components/spotlight/analytics/dashboard_component.rb', line 7

def current_exhibit
  @current_exhibit
end

#datesObject (readonly)

Returns the value of attribute dates.



7
8
9
# File 'app/components/spotlight/analytics/dashboard_component.rb', line 7

def dates
  @dates
end

Instance Method Details

#page_analyticsObject



23
24
25
# File 'app/components/spotlight/analytics/dashboard_component.rb', line 23

def page_analytics
  @page_analytics ||= current_exhibit.page_analytics(dates, page_url)
end

#page_urlObject



19
20
21
# File 'app/components/spotlight/analytics/dashboard_component.rb', line 19

def page_url
  @page_url ||= helpers.exhibit_root_path(current_exhibit)
end

#results?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'app/components/spotlight/analytics/dashboard_component.rb', line 15

def results?
  page_analytics.totals.to_h.present? || search_analytics.totals.to_h.present?
end

#search_analyticsObject



27
28
29
# File 'app/components/spotlight/analytics/dashboard_component.rb', line 27

def search_analytics
  @search_analytics ||= current_exhibit.analytics(dates, page_url)
end