Sha256: 1deee7d472c4e4a0695ff34841302003c305c3aee0fdc1cf555cf1030650dfae

Contents?: true

Size: 586 Bytes

Versions: 4

Compression:

Stored size: 586 Bytes

Contents

class Matey::NewUsersComponent < Matey::ApplicationComponent
  def initialize(users:, time_window: 1.week, color_scheme: "neutral")
    @current_period = users.where(created_at: time_window.ago..Time.current).count
    previous_period = users.where(created_at: (2 * time_window).ago..time_window.ago).count

    @change_new_number = @current_period - previous_period
    @change_new_percent = ((@change_new_number.to_f / ((previous_period == 0) ? 1 : previous_period)) * 100).truncate(2)

    @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/new_users_component.rb
matey-0.1.6 app/components/matey/new_users_component.rb
matey-0.1.5 app/components/matey/new_users_component.rb
matey-0.1.4 app/components/matey/new_users_component.rb