Sha256: 8fa5bdbcb2566212918173101e9eb381181fdd53e93d7d0a8522c2674ecb02b8

Contents?: true

Size: 1.12 KB

Versions: 34

Compression:

Stored size: 1.12 KB

Contents

module Workarea
  module Metrics
    class ProductByWeek
      include ByWeek
      include RevenueChange

      field :_id, type: String, default: -> { "#{reporting_on.strftime('%Y%m%d')}-#{product_id}" }
      field :product_id, type: String
      field :views, type: Integer, default: 0
      field :views_percentile, type: Integer
      field :orders, type: Integer, default: 0
      field :units_sold, type: Integer, default: 0
      field :discounted_units_sold, type: Integer, default: 0
      field :merchandise, type: Float, default: 0.0
      field :discounts, type: Float, default: 0.0
      field :tax, type: Float, default: 0.0
      field :average_discount, type: Float, default: 0.0
      field :discount_rate, type: Float, default: 0.0
      field :conversion_rate, type: Float, default: 0.0

      index(product_id: 1)
      index(views_percentile: 1, reporting_on: 1, conversion_rate: 1)

      scope :by_product, ->(id) { where(product_id: id) }
      scope :by_views_percentile, ->(range) { where(views_percentile: range) }

      def self.append_last_week!
        append!(ProductForLastWeek.all)
      end
    end
  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
workarea-core-3.4.45 app/models/workarea/metrics/product_by_week.rb
workarea-core-3.4.44 app/models/workarea/metrics/product_by_week.rb
workarea-core-3.4.43 app/models/workarea/metrics/product_by_week.rb
workarea-core-3.4.42 app/models/workarea/metrics/product_by_week.rb
workarea-core-3.4.41 app/models/workarea/metrics/product_by_week.rb
workarea-core-3.4.40 app/models/workarea/metrics/product_by_week.rb
workarea-core-3.4.39 app/models/workarea/metrics/product_by_week.rb
workarea-core-3.4.38 app/models/workarea/metrics/product_by_week.rb
workarea-core-3.4.37 app/models/workarea/metrics/product_by_week.rb
workarea-core-3.4.36 app/models/workarea/metrics/product_by_week.rb
workarea-core-3.4.35 app/models/workarea/metrics/product_by_week.rb
workarea-core-3.4.34 app/models/workarea/metrics/product_by_week.rb
workarea-core-3.4.33 app/models/workarea/metrics/product_by_week.rb
workarea-core-3.4.32 app/models/workarea/metrics/product_by_week.rb
workarea-core-3.4.31 app/models/workarea/metrics/product_by_week.rb
workarea-core-3.4.30 app/models/workarea/metrics/product_by_week.rb
workarea-core-3.4.29 app/models/workarea/metrics/product_by_week.rb
workarea-core-3.4.28 app/models/workarea/metrics/product_by_week.rb
workarea-core-3.4.27 app/models/workarea/metrics/product_by_week.rb
workarea-core-3.4.26 app/models/workarea/metrics/product_by_week.rb