Class: InnerPerformance::EventsController

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

Constant Summary collapse

RESULTS_PER_PAGE =
50

Instance Method Summary collapse

Instance Method Details

#indexObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/controllers/inner_performance/events_controller.rb', line 7

def index
  @current_page = params[:page].presence&.to_i

  if current_page.nil? || current_page < 1
    @current_page = 1
  end

  @q = InnerPerformance::Event
    .all
    .limit(RESULTS_PER_PAGE)
    .offset(RESULTS_PER_PAGE * (@current_page - 1))
    .ransack(params[:q])

  @q.sorts = "created_at desc" if @q.sorts.empty?

  @events = @q.result
end

#showObject



25
26
27
28
# File 'app/controllers/inner_performance/events_controller.rb', line 25

def show
  @event = InnerPerformance::Event.find(params[:id])
  @traces = @event.traces.order(created_at: :asc)
end