Class: Flightdeck::RecurringTasksController

Inherits:
ApplicationController show all
Includes:
Toasts
Defined in:
app/controllers/flightdeck/recurring_tasks_controller.rb

Constant Summary

Constants inherited from ApplicationController

ApplicationController::UNCONFIGURED_MESSAGE

Instance Method Summary collapse

Methods inherited from ApplicationController

host_authenticated?

Instance Method Details

#indexObject



9
10
# File 'app/controllers/flightdeck/recurring_tasks_controller.rb', line 9

def index
end

#runObject

"Run now" is the task's own enqueue, so the recurring execution is recorded exactly as the scheduler would have recorded it.



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'app/controllers/flightdeck/recurring_tasks_controller.rb', line 14

def run
  row = @catalog.find(params[:id])
  return missing unless row

  active_job = row.task.enqueue(at: Time.current)
  load_catalog

  if active_job
    @enqueued_job_id = active_job.try(:provider_job_id)
    toast "Enqueued #{row.key}#{job_reference}."
  else
    toast "#{row.key} was not enqueued — it has already run for this slot, or the job " \
          "class refused to enqueue.", level: :error
  end

  respond_with_toast recurring_frame, fallback: recurring_tasks_path
end