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.45 app/controllers/workarea/storefront/recent_views_controller.rb
workarea-storefront-3.4.44 app/controllers/workarea/storefront/recent_views_controller.rb
workarea-storefront-3.4.43 app/controllers/workarea/storefront/recent_views_controller.rb
workarea-storefront-3.4.42 app/controllers/workarea/storefront/recent_views_controller.rb
workarea-storefront-3.4.41 app/controllers/workarea/storefront/recent_views_controller.rb
workarea-storefront-3.4.40 app/controllers/workarea/storefront/recent_views_controller.rb
workarea-storefront-3.4.39 app/controllers/workarea/storefront/recent_views_controller.rb
workarea-storefront-3.4.38 app/controllers/workarea/storefront/recent_views_controller.rb
workarea-storefront-3.4.37 app/controllers/workarea/storefront/recent_views_controller.rb
workarea-storefront-3.4.36 app/controllers/workarea/storefront/recent_views_controller.rb
workarea-storefront-3.4.35 app/controllers/workarea/storefront/recent_views_controller.rb
workarea-storefront-3.4.34 app/controllers/workarea/storefront/recent_views_controller.rb
workarea-storefront-3.4.33 app/controllers/workarea/storefront/recent_views_controller.rb
workarea-storefront-3.4.32 app/controllers/workarea/storefront/recent_views_controller.rb
workarea-storefront-3.4.31 app/controllers/workarea/storefront/recent_views_controller.rb
workarea-storefront-3.4.30 app/controllers/workarea/storefront/recent_views_controller.rb
workarea-storefront-3.4.29 app/controllers/workarea/storefront/recent_views_controller.rb
workarea-storefront-3.4.28 app/controllers/workarea/storefront/recent_views_controller.rb
workarea-storefront-3.4.27 app/controllers/workarea/storefront/recent_views_controller.rb
workarea-storefront-3.4.26 app/controllers/workarea/storefront/recent_views_controller.rb