Sha256: 95eebe43bc8fef432024bf49baeb174580139cacf44f6d0471a235be2d4fe6d1

Contents?: true

Size: 1.31 KB

Versions: 62

Compression:

Stored size: 1.31 KB

Contents

module Workarea
  module Metrics
    class SearchByWeek
      include ByWeek
      include RevenueChange

      field :_id, type: String, default: -> { "#{reporting_on.strftime('%Y%m%d')}-#{query_id}" }
      field :query_id, type: String
      field :total_results, type: Integer
      field :query_string, type: String
      field :searches, type: Integer, default: 0
      field :searches_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(query_id: 1)
      index(searches_percentile: 1, reporting_on: 1, conversion_rate: 1)

      scope :by_query, ->(id) { where(query_id: id) }
      scope :by_searches_percentile, ->(range) { where(searches_percentile: range) }
      scope :has_results, -> { where(:total_results.gt => 0) }
      scope :most_searched, -> { desc(:searches) }

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

Version data entries

62 entries across 62 versions & 1 rubygems

Version Path
workarea-core-3.5.27 app/models/workarea/metrics/search_by_week.rb
workarea-core-3.5.26 app/models/workarea/metrics/search_by_week.rb
workarea-core-3.4.45 app/models/workarea/metrics/search_by_week.rb
workarea-core-3.5.25 app/models/workarea/metrics/search_by_week.rb
workarea-core-3.5.23 app/models/workarea/metrics/search_by_week.rb
workarea-core-3.4.44 app/models/workarea/metrics/search_by_week.rb
workarea-core-3.5.22 app/models/workarea/metrics/search_by_week.rb
workarea-core-3.4.43 app/models/workarea/metrics/search_by_week.rb
workarea-core-3.5.21 app/models/workarea/metrics/search_by_week.rb
workarea-core-3.4.42 app/models/workarea/metrics/search_by_week.rb
workarea-core-3.5.20 app/models/workarea/metrics/search_by_week.rb
workarea-core-3.4.41 app/models/workarea/metrics/search_by_week.rb
workarea-core-3.5.19 app/models/workarea/metrics/search_by_week.rb
workarea-core-3.4.40 app/models/workarea/metrics/search_by_week.rb
workarea-core-3.5.18 app/models/workarea/metrics/search_by_week.rb
workarea-core-3.4.39 app/models/workarea/metrics/search_by_week.rb
workarea-core-3.5.17 app/models/workarea/metrics/search_by_week.rb
workarea-core-3.4.38 app/models/workarea/metrics/search_by_week.rb
workarea-core-3.5.16 app/models/workarea/metrics/search_by_week.rb
workarea-core-3.4.37 app/models/workarea/metrics/search_by_week.rb