jobs: add ability to search jobs on /jobs page.
Add ability to search jobs on the /jobs page by job type or by status. Fixes #2577 (Search filters for delayed jobs). This wasn't possible before with DelayedJobs because it stored the job data in a YAML string, which made it difficult to search jobs by type. GoodJobs stores job data in a JSON object, which is easier to search in Postgres.
This commit is contained in:
@@ -4,30 +4,30 @@ class JobsController < ApplicationController
|
||||
respond_to :html, :xml, :json, :js
|
||||
|
||||
def index
|
||||
@jobs = authorize GoodJob::ActiveJobJob.order(created_at: :desc).extending(PaginationExtension).paginate(params[:page], limit: params[:limit]), policy_class: GoodJobPolicy
|
||||
@jobs = authorize BackgroundJob.paginated_search(params)
|
||||
respond_with(@jobs)
|
||||
end
|
||||
|
||||
def cancel
|
||||
@job = authorize GoodJob::ActiveJobJob.find(params[:id]), policy_class: GoodJobPolicy
|
||||
@job = authorize BackgroundJob.find(params[:id])
|
||||
@job.discard_job("Canceled")
|
||||
respond_with(@job)
|
||||
end
|
||||
|
||||
def retry
|
||||
@job = authorize GoodJob::ActiveJobJob.find(params[:id]), policy_class: GoodJobPolicy
|
||||
@job = authorize BackgroundJob.find(params[:id])
|
||||
@job.retry_job
|
||||
respond_with(@job)
|
||||
end
|
||||
|
||||
def run
|
||||
@job = authorize GoodJob::ActiveJobJob.find(params[:id]), policy_class: GoodJobPolicy
|
||||
@job = authorize BackgroundJob.find(params[:id])
|
||||
@job.reschedule_job
|
||||
respond_with(@job)
|
||||
end
|
||||
|
||||
def destroy
|
||||
@job = authorize GoodJob::ActiveJobJob.find(params[:id]), policy_class: GoodJobPolicy
|
||||
@job = authorize BackgroundJob.find(params[:id])
|
||||
@job.destroy
|
||||
respond_with(@job)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user