Sha256: 275046fcfd18a2fa01c4f016a3c9c3709149ebef844f8bc4b4f693a33ba1fd6d

Contents?: true

Size: 1.22 KB

Versions: 28

Compression:

Stored size: 1.22 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
      field :units_canceled, type: Integer, default: 0
      field :refund, 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

28 entries across 28 versions & 1 rubygems

Version Path
workarea-core-3.5.27 app/models/workarea/metrics/product_by_week.rb
workarea-core-3.5.26 app/models/workarea/metrics/product_by_week.rb
workarea-core-3.5.25 app/models/workarea/metrics/product_by_week.rb
workarea-core-3.5.23 app/models/workarea/metrics/product_by_week.rb
workarea-core-3.5.22 app/models/workarea/metrics/product_by_week.rb
workarea-core-3.5.21 app/models/workarea/metrics/product_by_week.rb
workarea-core-3.5.20 app/models/workarea/metrics/product_by_week.rb
workarea-core-3.5.19 app/models/workarea/metrics/product_by_week.rb
workarea-core-3.5.18 app/models/workarea/metrics/product_by_week.rb
workarea-core-3.5.17 app/models/workarea/metrics/product_by_week.rb
workarea-core-3.5.16 app/models/workarea/metrics/product_by_week.rb
workarea-core-3.5.15 app/models/workarea/metrics/product_by_week.rb
workarea-core-3.5.14 app/models/workarea/metrics/product_by_week.rb
workarea-core-3.5.13 app/models/workarea/metrics/product_by_week.rb
workarea-core-3.5.12 app/models/workarea/metrics/product_by_week.rb
workarea-core-3.5.11 app/models/workarea/metrics/product_by_week.rb
workarea-core-3.5.10 app/models/workarea/metrics/product_by_week.rb
workarea-core-3.5.9 app/models/workarea/metrics/product_by_week.rb
workarea-core-3.5.8 app/models/workarea/metrics/product_by_week.rb
workarea-core-3.5.7 app/models/workarea/metrics/product_by_week.rb