Sha256: 50cc58c07803a15ac8554d463673564f650948e416790c98f25f19881ed3b687

Contents?: true

Size: 1.2 KB

Versions: 27

Compression:

Stored size: 1.2 KB

Contents

module Workarea
  module Metrics
    class SearchByDay
      include ByDay

      field :query_id, type: String
      field :query_string, type: String
      field :searches, type: Integer, default: 0
      field :total_results, type: Integer, default: 0
      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 :shipping, type: Float, default: 0.0
      field :discounts, type: Float, default: 0.0
      field :tax, type: Float, default: 0.0
      field :revenue, type: Float, default: 0.0

      index(reporting_on: 1, total_results: 1)
      index(query_id: 1)

      scope :by_query_id, ->(id) { where(query_id: id) }

      def self.save_search(query_string, total_results, at: Time.current)
        query_string = QueryString.new(query_string)
        return if query_string.id.blank? || query_string.short? || total_results.blank?

        inc(
          key: { query_id: query_string.id },
          set: { total_results: total_results.to_i, query_string: query_string.pretty },
          at: at,
          searches: 1
        )
      end
    end
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

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