Sha256: abc8971b041daee734ff63543bf6f0c9220db0b974e95f192648b7c6647bf3a8

Contents?: true

Size: 625 Bytes

Versions: 3

Compression:

Stored size: 625 Bytes

Contents

require "ahoy_matey"
require "groupdate"

class Matey::VisitsByDayOfWeekComponent < Matey::ApplicationComponent
  def initialize(visits:, time_window: 1.month, exclude_days: [], color_scheme: "neutral")
    @visits = visits
    @time_window = time_window
    @exclude_days = exclude_days
    @color_scheme = color_scheme(scheme: color_scheme)
  end

  # group visits by day in provided time window
  def visits_by_day_of_week
    visits_by_day_of_week = @visits.group_by_day_of_week(:started_at, format: "%A", range: @time_window.ago..).count
    visits_by_day_of_week.except!(*@exclude_days) if @exclude_days.any?
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

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