Class: Workarea::Storefront::RecentViewsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/workarea/storefront/recent_views_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#current_layout, #current_user_info, #health_check, #layout_content

Methods included from OrderLookup

#lookup_order, #lookup_order=

Methods included from UserActivity

#current_user_activity_id, #user_activity

Methods included from CurrentCheckout

#clear_current_order, #completed_order, #completed_order=, #current_checkout, #current_order, #current_order=, #current_shipping, #current_shippings

Methods included from HttpCaching

#cache_page, #http_caching?

Instance Method Details

#showObject



6
7
8
9
10
11
# File 'app/controllers/workarea/storefront/recent_views_controller.rb', line 6

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

#updateObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'app/controllers/workarea/storefront/recent_views_controller.rb', line 13

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