Sha256: 422b277ca9e9fafb8620a576ad2f156dd76cd51576395f64f7829fce01de6f1a
Contents?: true
Size: 1.1 KB
Versions: 2
Compression:
Stored size: 1.1 KB
Contents
module DelayedJobProgress class JobsController < ActionController::Base before_action :load_job, only: [:show, :destroy, :reload] def index jobs = Delayed::Job if params[:record_type].present? && params[:record_id].present? jobs = jobs.where(record_type: params[:record_type], record_id: params[:record_id]) end if params[:identifier].present? jobs = jobs.where(identifier: params[:identifier]) end render json: jobs.all, methods: :status end def show render json: @job, methods: :status end def destroy @job.destroy(:force) head :no_content end def reload @job.update_columns( run_at: Time.now, failed_at: nil, completed_at: nil, locked_by: nil, locked_at: nil, last_error: nil, attempts: 0 ) render json: @job end protected def load_job @job = Delayed::Job.find(params[:id]) rescue ActiveRecord::RecordNotFound render json: {error: 'Job not found'}, status: :not_found end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
delayed_job_progress-0.0.3 | app/controllers/delayed_job_progress/jobs_controller.rb |
delayed_job_progress-0.0.2 | app/controllers/delayed_job_progress/jobs_controller.rb |