Sha256: 370d8893525e882b77d4ac478fda3135abae55cd60d8c504b7d0e0cd1e791b01

Contents?: true

Size: 1.16 KB

Versions: 3

Compression:

Stored size: 1.16 KB

Contents

module Sidekiq
  module Monitor
    module Api
      class JobsController < ActionController::Base
        protect_from_forgery

        def index
          render json: JobsDatatable.new(view_context)
        end

        def custom_views
          job = Job.find(params[:id])
          render json: {}, status: 404 and return if job.blank?

          views = CustomViews.for_job(job)
          views = views.collect do |view|
            {
              name: view[:name],
              html: render_to_string(view[:path], locals: {job: job, path: view[:path]})
            }
          end
          render json: views, status: :ok
        end

        def retry
          id = params[:id]
          render json: {}, status: 404 and return if id.blank?

          job = Job.find(id)
          render json: {}, status: 404 and return if job.blank?

          args = job.args
          worker = job.class_name.constantize
          worker.perform_async(*args)
          render json: {}, status: :ok
        end

        def clean
          cleaner = Sidekiq::Monitor::Cleaner.new
          cleaner.clean
          render json: {}, status: :ok
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
sidekiq_monitor-0.0.6 app/controllers/sidekiq/monitor/api/jobs_controller.rb
sidekiq_monitor-0.0.5 app/controllers/sidekiq/monitor/api/jobs_controller.rb
sidekiq_monitor-0.0.4 app/controllers/sidekiq/monitor/api/jobs_controller.rb