Class: Workarea::Api::Storefront::RecentViewsController

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

Instance Method Summary collapse

Methods inherited from ApplicationController

#assert_current_metrics_id, #cache_page, #skip_session

Methods included from Authentication

#authentication?, #current_user, find_user

Instance Method Details

#showObject



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

def show
  @recent_views = Workarea::Storefront::UserActivityViewModel.new(
    current_metrics
  )
end

#updateObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'app/controllers/workarea/api/storefront/recent_views_controller.rb', line 13

def update
  product_ids = Array.wrap(params[:product_id])
  category_ids = Array.wrap(params[:category_id])
  search_ids = Array.wrap(params[:search])

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

  head :ok
end