Class: ActiveJob::Notificare::ExecutionsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/active_job/notificare/executions_controller.rb

Constant Summary collapse

PER_PAGE =
25

Instance Method Summary collapse

Instance Method Details

#indexObject



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'app/controllers/active_job/notificare/executions_controller.rb', line 8

def index
  scope = Execution.recent
  scope = scope.where(status: params[:status]) if params[:status].present?
  scope = scope.where(job_class: params[:job_class]) if params[:job_class].present?

  @page = [ params.fetch(:page, 1).to_i, 1 ].max
  @total_count = scope.count
  @total_pages = [ (@total_count.to_f / PER_PAGE).ceil, 1 ].max
  @page = [ @page, @total_pages ].min
  @executions = scope.limit(PER_PAGE).offset((@page - 1) * PER_PAGE)
  @statuses = Execution.statuses.keys
  @job_classes = Execution.distinct.pluck(:job_class).sort
end

#showObject



22
23
24
25
26
27
# File 'app/controllers/active_job/notificare/executions_controller.rb', line 22

def show
  @execution = Execution.find(params[:id])
  @notifications = Notification.where(job_id: @execution.job_id).limit(50)
rescue ActiveRecord::RecordNotFound
  head :not_found
end