Module: ResqueAdmin::Scheduler::Server::ServerMethods
- Defined in:
- lib/resque/scheduler/server.rb,
lib/resque_admin/scheduler/server.rb
Instance Method Summary collapse
- #delayed ⇒ Object
- #delayed_cancel_now ⇒ Object
- #delayed_clear ⇒ Object
- #delayed_jobs_klass ⇒ Object
- #delayed_queue_now ⇒ Object
- #delayed_search ⇒ Object
- #delayed_timestamp ⇒ Object
- #delete_schedule ⇒ Object
- #schedule ⇒ Object
- #schedule_requeue ⇒ Object
- #schedule_requeue_with_params ⇒ Object
Instance Method Details
#delayed ⇒ Object
83 84 85 |
# File 'lib/resque/scheduler/server.rb', line 83 def delayed erb scheduler_template('delayed') end |
#delayed_cancel_now ⇒ Object
125 126 127 128 129 130 131 |
# File 'lib/resque/scheduler/server.rb', line 125 def delayed_cancel_now klass = ResqueAdmin::Scheduler::Util.constantize(params['klass']) = params['timestamp'] args = ResqueAdmin.decode params['args'] ResqueAdmin.(, klass, *args) redirect u('/delayed') end |
#delayed_clear ⇒ Object
133 134 135 136 |
# File 'lib/resque/scheduler/server.rb', line 133 def delayed_clear ResqueAdmin.reset_delayed_queue redirect u('delayed') end |
#delayed_jobs_klass ⇒ Object
87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/resque/scheduler/server.rb', line 87 def delayed_jobs_klass begin klass = ResqueAdmin::Scheduler::Util.constantize(params[:klass]) @args = JSON.load(URI.decode(params[:args])) @timestamps = ResqueAdmin.scheduled_at(klass, *@args) rescue @timestamps = [] end erb scheduler_template('delayed_schedules') end |
#delayed_queue_now ⇒ Object
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/resque/scheduler/server.rb', line 108 def delayed_queue_now = params['timestamp'].to_i formatted_time = Time.at().strftime( ::ResqueAdmin::Scheduler::Server::TIMESTAMP_FORMAT ) if > 0 unless ResqueAdmin::Scheduler.enqueue_next_item() @error_message = "Unable to remove item at #{formatted_time}" end else @error_message = "Incorrect timestamp #{formatted_time}" end erb scheduler_template('delayed') end |
#delayed_search ⇒ Object
99 100 101 102 |
# File 'lib/resque/scheduler/server.rb', line 99 def delayed_search @jobs = find_job(params[:search]) erb scheduler_template('search') end |
#delayed_timestamp ⇒ Object
104 105 106 |
# File 'lib/resque/scheduler/server.rb', line 104 def erb scheduler_template('delayed_timestamp') end |
#delete_schedule ⇒ Object
75 76 77 78 79 80 81 |
# File 'lib/resque/scheduler/server.rb', line 75 def delete_schedule if ResqueAdmin::Scheduler.dynamic job_name = params['job_name'] || params[:job_name] ResqueAdmin.remove_schedule(job_name) end redirect u('/schedule') end |
#schedule ⇒ Object
39 40 41 42 |
# File 'lib/resque/scheduler/server.rb', line 39 def schedule ResqueAdmin.reload_schedule! if ResqueAdmin::Scheduler.dynamic erb scheduler_template('scheduler') end |
#schedule_requeue ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/resque/scheduler/server.rb', line 44 def schedule_requeue @job_name = params['job_name'] || params[:job_name] config = ResqueAdmin.schedule[@job_name] @parameters = config['parameters'] || config[:parameters] if @parameters erb scheduler_template('requeue-params') else ResqueAdmin::Scheduler.enqueue_from_config(config) redirect u('/overview') end end |
#schedule_requeue_with_params ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/resque/scheduler/server.rb', line 56 def schedule_requeue_with_params job_name = params['job_name'] || params[:job_name] config = ResqueAdmin.schedule[job_name] # Build args hash from post data (removing the job name) submitted_args = params.reject do |key, _value| key == 'job_name' || key == :job_name end # Merge constructed args hash with existing args hash for # the job, if it exists config_args = config['args'] || config[:args] || {} config_args = config_args.merge(submitted_args) # Insert the args hash into config and queue the resque_admin job config = config.merge('args' => config_args) ResqueAdmin::Scheduler.enqueue_from_config(config) redirect u('/overview') end |