Class: Spotlight::Analytics::DashboardComponent
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- Spotlight::Analytics::DashboardComponent
- Defined in:
- app/components/spotlight/analytics/dashboard_component.rb
Overview
Display Analytics
Instance Attribute Summary collapse
-
#current_exhibit ⇒ Object
readonly
Returns the value of attribute current_exhibit.
-
#dates ⇒ Object
readonly
Returns the value of attribute dates.
Instance Method Summary collapse
-
#initialize(current_exhibit:) ⇒ DashboardComponent
constructor
A new instance of DashboardComponent.
- #page_analytics ⇒ Object
- #page_url ⇒ Object
- #results? ⇒ Boolean
- #search_analytics ⇒ Object
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_exhibit ⇒ Object (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 |
#dates ⇒ Object (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_analytics ⇒ Object
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_url ⇒ Object
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
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_analytics ⇒ Object
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 |