Class: Matey::DailyActiveUsersComponent
- Inherits:
-
ApplicationComponent
- Object
- ViewComponent::Base
- ApplicationComponent
- Matey::DailyActiveUsersComponent
- Defined in:
- app/components/matey/daily_active_users_component.rb
Instance Method Summary collapse
-
#initialize(visits:, time_window:, color_scheme: "neutral") ⇒ DailyActiveUsersComponent
constructor
A new instance of DailyActiveUsersComponent.
Methods inherited from ApplicationComponent
Methods included from ColorSchemeHelper
Constructor Details
#initialize(visits:, time_window:, color_scheme: "neutral") ⇒ DailyActiveUsersComponent
Returns a new instance of DailyActiveUsersComponent.
2 3 4 5 6 7 8 9 10 |
# File 'app/components/matey/daily_active_users_component.rb', line 2 def initialize(visits:, time_window:, color_scheme: "neutral") @visits = visits @time_window = time_window visits_in_time_window = visits.where(started_at: time_window.ago..) @distinct_user_visits_by_day = visits_in_time_window.order(:day).group(:day).uniq.count # @distinct_user_visits_by_day2 = visits_in_time_window.order(:day).group("DATE(started_at)").map { |k, v| [k, v] }.sort @color_scheme = color_scheme(scheme: color_scheme) end |