Sha256: 2f27ea3a1632c4f35e4b3b4238413c35e42d3490b6ac5c9a64f39036f40f0abd

Contents?: true

Size: 621 Bytes

Versions: 4

Compression:

Stored size: 621 Bytes

Contents

class Matey::TopVisitedPagesTableComponent < Matey::ApplicationComponent
  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
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
matey-0.2.0 app/components/matey/top_visited_pages_table_component.rb
matey-0.1.6 app/components/matey/top_visited_pages_table_component.rb
matey-0.1.5 app/components/matey/top_visited_pages_table_component.rb
matey-0.1.4 app/components/matey/top_visited_pages_table_component.rb