Class: SpectatorSport::EventsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/spectator_sport/events_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'app/controllers/spectator_sport/events_controller.rb', line 8

def create
  data = if params.key?(:events) && (params.key?(:recordingId) || params.key?(:windowId))
    params.slice(:sessionId, :recordingId, :windowId, :events, :tags, :labels).stringify_keys
  else
    # beacon sends JSON in the request body
    JSON.parse(request.body.read).slice("sessionId", "recordingId", "windowId", "events", "tags", "labels")
  end

  # `windowId` is the legacy name for `recordingId`; accept either for backward compatibility.
  data["recordingId"] ||= data["windowId"]
  data["windowId"] ||= data["recordingId"]

  events = data["events"]

  if SpectatorSport::Recording.migrated?
    create_recording(data, events)
  else
    create_session_window(data, events)
  end

  render json: { message: "ok" }
end

#indexObject



5
6
# File 'app/controllers/spectator_sport/events_controller.rb', line 5

def index
end