Sha256: 0cf10e25352f0c6d4964c0134445f5acf14e02879d2f89ed47eb181aa8a77fd3

Contents?: true

Size: 1.71 KB

Versions: 1

Compression:

Stored size: 1.71 KB

Contents

module ResqueWeb
  module Plugins
    module ResqueScheduler
      # Controller for delayed jobs. These have been added to the queue by the
      # application, so here, they can be run immediately, deleted from the
      # queue, or rescheduled.
      class DelayedController < ResqueWeb::ApplicationController
        def index
          @start = params[:start].to_i
          @number_to_show = 20
          @total_number_of_delayed_jobs = Resque.delayed_queue_schedule_size
          @timestamps = Resque.delayed_queue_peek(@start, @number_to_show)
        end

        def jobs_klass
          klass = Resque::Scheduler::Util.constantize(params[:klass])
          @args = JSON.load(URI.decode(params[:args]))
          @timestamps = Resque.scheduled_at(klass, *@args)
        rescue
          @timestamps = []
        end

        def search
          @jobs = JobFinder.new(params[:search]).find_jobs
        end

        def cancel_now
          klass = Resque::Scheduler::Util.constantize(params['klass'])
          timestamp = params['timestamp']
          args = Resque.decode params['args']
          Resque.remove_delayed_job_from_timestamp(timestamp, klass, *args)
          redirect_to Engine.app.url_helpers.delayed_path
        end

        def clear
          Resque.reset_delayed_queue
          redirect_to Engine.app.url_helpers.delayed_path
        end

        def queue_now
          timestamp = params['timestamp'].to_i
          if timestamp > 0
            Resque::Scheduler.enqueue_delayed_items_for_timestamp(timestamp)
          end
          redirect_to ResqueWeb::Engine.app.url_helpers.overview_path
        end

        def timestamp
          @timestamp = params[:timestamp].to_i
        end

      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
resque-scheduler-web-0.0.1 app/controllers/resque_web/plugins/resque_scheduler/delayed_controller.rb