Class: SolidQueueWeb::ScheduledJobsController
Constant Summary
ApplicationController::PERIOD_DURATIONS, ApplicationController::STAGGER_INTERVALS
Instance Method Summary
collapse
Instance Method Details
#create ⇒ Object
3
4
5
6
7
8
9
10
11
12
13
14
15
|
# File 'app/controllers/solid_queue_web/scheduled_jobs_controller.rb', line 3
def create
@period = params[:period].presence_in(PERIOD_DURATIONS.keys)
job_ids = scheduled_scope.pluck("solid_queue_jobs.id")
SolidQueue::ScheduledExecution.where(job_id: job_ids).update_all(scheduled_at: 1.second.ago)
SolidQueue::Job.where(id: job_ids).update_all(scheduled_at: 1.second.ago)
redirect_to jobs_path(status: "scheduled", period: @period),
notice: "#{job_ids.size} #{"job".pluralize(job_ids.size)} scheduled to run immediately."
rescue => e
redirect_to jobs_path(status: "scheduled", period: @period),
alert: "Could not run jobs: #{e.message}"
end
|
#update ⇒ Object
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'app/controllers/solid_queue_web/scheduled_jobs_controller.rb', line 17
def update
@execution = SolidQueue::ScheduledExecution.find(params[:id])
@period = params[:period].presence_in(PERIOD_DURATIONS.keys)
@run_now = params[:offset] == "now"
new_time = resolve_new_time(@execution, params[:offset])
@execution.update!(scheduled_at: new_time)
@execution.job.update!(scheduled_at: new_time)
respond_to do |format|
format.turbo_stream
format.html do
notice = @run_now ? "Job scheduled to run immediately." : "Job rescheduled by +#{params[:offset]}."
redirect_to jobs_path(status: "scheduled", period: @period), notice: notice
end
end
rescue ArgumentError => e
redirect_to jobs_path(status: "scheduled"), alert: e.message
rescue => e
redirect_to jobs_path(status: "scheduled"), alert: "Could not reschedule job: #{e.message}"
end
|