Class: Matey::TopVisitedPagesTableComponent
- Inherits:
-
ApplicationComponent
- Object
- ViewComponent::Base
- ApplicationComponent
- Matey::TopVisitedPagesTableComponent
- Defined in:
- app/components/matey/top_visited_pages_table_component.rb
Instance Method Summary collapse
-
#initialize(events:, time_window: 1.week, limit: 10, color_scheme: "neutral") ⇒ TopVisitedPagesTableComponent
constructor
A new instance of TopVisitedPagesTableComponent.
Methods inherited from ApplicationComponent
Methods included from ColorSchemeHelper
Constructor Details
#initialize(events:, time_window: 1.week, limit: 10, color_scheme: "neutral") ⇒ TopVisitedPagesTableComponent
Returns a new instance of TopVisitedPagesTableComponent.
2 3 4 5 6 7 8 9 10 11 12 |
# File 'app/components/matey/top_visited_pages_table_component.rb', line 2 def initialize(events:, time_window: 1.week, limit: 10, color_scheme: "neutral") # Group events by controller (:name) and action. Aggregate number of unique user actions @user_count_by_event = events.where(started_at: time_window.ago..).pluck(:landing_page).tally # Filter for the top 10 elements by user actions @user_count_by_event = @user_count_by_event.sort_by { |controller_name_and_action, count| count }.last(limit).reverse @time_window = time_window @color_scheme = color_scheme(scheme: color_scheme) end |