docbrown/app/controllers/feed_events_controller.rb
PJ 3f7d1fbc1a
Create feed impression and click events (#20043)
* getting started: model setup

* basic controller action & spec

* somewhat working click events

* pick up on impressions

* there was an attempt at batching without duplicates

* (better) bulk upsert service

* fix specs?

* touch up feed events JS

* end-to-end specs??

* workers wip

* fix failing user delete spec
2023-09-11 13:32:36 +01:00

26 lines
533 B
Ruby

class FeedEventsController < ApplicationMetalController
include ActionController::Head
FEED_EVENT_ALLOWED_PARAMS = %i[
article_id
article_position
category
context_type
].freeze
def create
if session_current_user_id
FeedEvents::BulkUpsert.call(feed_events_params)
end
head :ok
end
private
def feed_events_params
@feed_events_params ||= params[:feed_events].map do |event|
event.slice(*FEED_EVENT_ALLOWED_PARAMS).merge(user_id: session_current_user_id)
end
end
end