Sha256: 9bfe080a3c1b4974dd844a4f50859726412529be33296a77843492c1810acdf4

Contents?: true

Size: 1.37 KB

Versions: 12

Compression:

Stored size: 1.37 KB

Contents

module Workarea
  module Api
    module Storefront
      class AnalyticsController < Api::Storefront::ApplicationController
        def category_view
          Metrics::CategoryByDay.inc(key: { category_id: params[:category_id] }, views: 1)

          if current_metrics_id.present?
            Metrics::User.save_affinity(
              id: current_metrics_id,
              action: 'viewed',
              category_ids: params[:category_id]
            )
          end

          head :ok
        end

        def product_view
          Metrics::ProductByDay.inc(key: { product_id: params[:product_id] }, views: 1)

          if current_metrics_id.present?
            Metrics::User.save_affinity(
              id: current_metrics_id,
              action: 'viewed',
              product_ids: params[:product_id]
            )
          end

          head :ok
        end

        def search
          query_string = QueryString.new(params[:q])

          if query_string.present? && !query_string.short?
            Metrics::SearchByDay.save_search(params[:q], params[:total_results])

            if current_metrics_id.present?
              Metrics::User.save_affinity(
                id: current_metrics_id,
                action: 'viewed',
                search_ids: query_string.id
              )
            end
          end

          head :ok
        end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
workarea-api-4.5.6 storefront/app/controllers/workarea/api/storefront/analytics_controller.rb
workarea-api-storefront-4.5.6 app/controllers/workarea/api/storefront/analytics_controller.rb
workarea-api-4.5.5 storefront/app/controllers/workarea/api/storefront/analytics_controller.rb
workarea-api-storefront-4.5.5 app/controllers/workarea/api/storefront/analytics_controller.rb
workarea-api-4.5.4 storefront/app/controllers/workarea/api/storefront/analytics_controller.rb
workarea-api-storefront-4.5.4 app/controllers/workarea/api/storefront/analytics_controller.rb
workarea-api-4.5.3 storefront/app/controllers/workarea/api/storefront/analytics_controller.rb
workarea-api-storefront-4.5.3 app/controllers/workarea/api/storefront/analytics_controller.rb
workarea-api-4.5.2 storefront/app/controllers/workarea/api/storefront/analytics_controller.rb
workarea-api-storefront-4.5.2 app/controllers/workarea/api/storefront/analytics_controller.rb
workarea-api-4.5.0 storefront/app/controllers/workarea/api/storefront/analytics_controller.rb
workarea-api-storefront-4.5.0 app/controllers/workarea/api/storefront/analytics_controller.rb