Class: SpectatorSport::Dashboard::SessionWindowsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/spectator_sport/dashboard/session_windows_controller.rb

Instance Method Summary collapse

Instance Method Details

#destroyObject



31
32
33
34
35
36
37
38
39
# File 'app/controllers/spectator_sport/dashboard/session_windows_controller.rb', line 31

def destroy
  @session_window = SessionWindow.find(params[:id])
  @session_window.events.delete_all
  @session_window.session_window_tags.delete_all if SpectatorSport::SessionWindowTag.migrated?
  @session_window.labels.delete_all if SpectatorSport::Label.migrated?
  @session_window.delete

  redirect_to root_path
end

#detailsObject



27
28
29
# File 'app/controllers/spectator_sport/dashboard/session_windows_controller.rb', line 27

def details
  @session_window = SessionWindow.find(params[:id])
end

#eventsObject



16
17
18
19
20
21
22
23
24
25
# File 'app/controllers/spectator_sport/dashboard/session_windows_controller.rb', line 16

def events
  response.content_type = "text/vnd.turbo-stream.html"
  return head(:ok) if params[:after_event_id].blank?

  session_window = SessionWindow.find(params[:id])
  previous_event = session_window.events.find_by(id: params[:after_event_id])
  @events = session_window.events.page_after(previous_event)

  render layout: false
end

#indexObject



4
5
6
7
8
# File 'app/controllers/spectator_sport/dashboard/session_windows_controller.rb', line 4

def index
  @session_windows = SessionWindow.order(:created_at).limit(50).reverse_order
  @session_windows = @session_windows.includes(:session_window_tags) if SpectatorSport::SessionWindowTag.migrated?
  @session_windows = @session_windows.includes(:labels) if SpectatorSport::Label.migrated?
end

#showObject



10
11
12
13
14
# File 'app/controllers/spectator_sport/dashboard/session_windows_controller.rb', line 10

def show
  @session_window = SessionWindow.find(params[:id])
  @events = @session_window.events.page_after(nil)
  @labels = SpectatorSport::Label.migrated? ? @session_window.labels.to_a : []
end