Sha256: bba7be28c9ba942f9c3b1c0a3703883d73fb27e075ee3c5f70595bfc5f79c61b

Contents?: true

Size: 1.19 KB

Versions: 34

Compression:

Stored size: 1.19 KB

Contents

module Workarea
  class Storefront::RecentViewsController < Storefront::ApplicationController
    skip_before_action :verify_authenticity_token
    before_action :block_robots

    def show
      if stale?(etag: user_activity, last_modified: user_activity.updated_at)
        @recent_views = Storefront::UserActivityViewModel.new(user_activity)
        render params[:view].in?(allowed_alt_views) ? params[:view] : :show
      end
    end

    def update
      if params[:product_id].present?
        Recommendation::UserActivity.save_product(
          current_user_activity_id,
          params[:product_id]
        )
      end

      if params[:category_id].present?
        Recommendation::UserActivity.save_category(
          current_user_activity_id,
          params[:category_id]
        )
      end

      if params[:search].present?
        Recommendation::UserActivity.save_search(
          current_user_activity_id,
          params[:search]
        )
      end

      head :ok
    end

    private

    def allowed_alt_views
      ['aside', 'narrow']
    end

    def block_robots
      if Robots.is_robot?(request.user_agent)
        head :forbidden
        return false
      end
    end
  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
workarea-storefront-3.4.25 app/controllers/workarea/storefront/recent_views_controller.rb
workarea-storefront-3.4.24 app/controllers/workarea/storefront/recent_views_controller.rb
workarea-storefront-3.4.23 app/controllers/workarea/storefront/recent_views_controller.rb
workarea-storefront-3.4.22 app/controllers/workarea/storefront/recent_views_controller.rb
workarea-storefront-3.4.21 app/controllers/workarea/storefront/recent_views_controller.rb
workarea-storefront-3.4.20 app/controllers/workarea/storefront/recent_views_controller.rb
workarea-storefront-3.4.19 app/controllers/workarea/storefront/recent_views_controller.rb
workarea-storefront-3.4.18 app/controllers/workarea/storefront/recent_views_controller.rb
workarea-storefront-3.4.17 app/controllers/workarea/storefront/recent_views_controller.rb
workarea-storefront-3.4.16 app/controllers/workarea/storefront/recent_views_controller.rb
workarea-storefront-3.4.15 app/controllers/workarea/storefront/recent_views_controller.rb
workarea-storefront-3.4.14 app/controllers/workarea/storefront/recent_views_controller.rb
workarea-storefront-3.4.13 app/controllers/workarea/storefront/recent_views_controller.rb
workarea-storefront-3.4.12 app/controllers/workarea/storefront/recent_views_controller.rb