Class: JobBoard::JobsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- JobBoard::JobsController
- Defined in:
- app/controllers/job_board/jobs_controller.rb
Instance Method Summary collapse
- #discard ⇒ Object
- #discard_all ⇒ Object
- #index ⇒ Object
- #retry ⇒ Object
- #retry_all ⇒ Object
- #show ⇒ Object
Instance Method Details
#discard ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 |
# File 'app/controllers/job_board/jobs_controller.rb', line 25 def discard job = find_job if job.status == :claimed redirect_back_or_to jobs_path, alert: "Job ##{job.id} is in progress and can't be discarded." elsif job.finished? redirect_back_or_to jobs_path, alert: "Job ##{job.id} is already finished." else job.discard redirect_to jobs_path(status: params[:status] || "failed"), notice: "Job ##{job.id} discarded." end end |
#discard_all ⇒ Object
46 47 48 49 50 51 52 53 |
# File 'app/controllers/job_board/jobs_controller.rb', line 46 def discard_all count = 0 failed_jobs_in_batches do |batch| SolidQueue::FailedExecution.discard_all_from_jobs(batch) count += batch.size end redirect_to failed_jobs_path, notice: "#{count} #{"job".pluralize(count)} discarded." end |
#index ⇒ Object
5 6 7 8 9 |
# File 'app/controllers/job_board/jobs_controller.rb', line 5 def index @page = @query.page(before: params[:before], limit: JobBoard.config.per_page) @counts = @query.counts @queues = LatencySla.sort(SolidQueue::Queue.all) end |
#retry ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'app/controllers/job_board/jobs_controller.rb', line 15 def retry job = find_job if job.failed_execution.present? job.retry redirect_back_or_to jobs_path(status: "failed"), notice: "Job ##{job.id} queued for retry." else redirect_back_or_to jobs_path, alert: "Job ##{job.id} is not failed, so it can't be retried." end end |
#retry_all ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'app/controllers/job_board/jobs_controller.rb', line 37 def retry_all count = 0 failed_jobs_in_batches do |batch| SolidQueue::FailedExecution.retry_all(batch) count += batch.size end redirect_to failed_jobs_path, notice: "#{count} #{"job".pluralize(count)} queued for retry." end |
#show ⇒ Object
11 12 13 |
# File 'app/controllers/job_board/jobs_controller.rb', line 11 def show @job = JobPresenter.new(find_job) end |