Class: Matey::BrowserOsBreakdownComponent

Inherits:
ApplicationComponent show all
Defined in:
app/components/matey/browser_os_breakdown_component.rb

Instance Method Summary collapse

Methods inherited from ApplicationComponent

#before_render

Methods included from ColorSchemeHelper

#color_scheme

Constructor Details

#initialize(visits:, time_window:, color_scheme: "neutral") ⇒ BrowserOsBreakdownComponent

Returns a new instance of BrowserOsBreakdownComponent.



2
3
4
5
6
7
8
9
10
# File 'app/components/matey/browser_os_breakdown_component.rb', line 2

def initialize(visits:, time_window:, color_scheme: "neutral")
  visits_in_time_window = visits.where(started_at: time_window.ago..)
  @visits_in_time_window = visits_in_time_window.count
  @browsers = visits_in_time_window.group(:browser).count
  @operating_systems = visits_in_time_window.group(:os).count
  @time_window = time_window

  @color_scheme = color_scheme(scheme: color_scheme)
end