Class: MaintenanceTasks::RunsController Private
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- MaintenanceTasks::RunsController
- Defined in:
- app/controllers/maintenance_tasks/runs_controller.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Class communicates with the Run model to persist info related to task runs. It defines actions for creating and pausing runs.
Constant Summary
Constants inherited from ApplicationController
ApplicationController::BULMA_CDN
Instance Method Summary collapse
-
#cancel ⇒ Object
private
Updates a Run status to cancelling.
-
#create(&block) ⇒ Object
private
Creates a Run for a given Task and redirects to the Task page.
-
#pause ⇒ Object
private
Updates a Run status to paused.
-
#resume ⇒ Object
private
Resumes a previously paused Run.
Instance Method Details
#cancel ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Updates a Run status to cancelling.
42 43 44 45 46 47 |
# File 'app/controllers/maintenance_tasks/runs_controller.rb', line 42 def cancel @run.cancel redirect_to(task_path(@run.task_name)) rescue ActiveRecord::RecordInvalid => error redirect_to(task_path(@run.task_name), alert: error.) end |
#create(&block) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Creates a Run for a given Task and redirects to the Task page.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'app/controllers/maintenance_tasks/runs_controller.rb', line 13 def create(&block) task = Runner.run( name: params.fetch(:task_id), csv_file: params[:csv_file], arguments: params.fetch(:task, {}).permit!.to_h, metadata: instance_exec(&MaintenanceTasks. || -> {}), &block ) redirect_to(task_path(task)) rescue ActiveRecord::RecordInvalid => error flash.now.alert = error. @task = TaskDataShow.prepare(error.record.task_name, arguments: error.record.arguments) render(template: "maintenance_tasks/tasks/show") rescue ActiveRecord::ValueTooLong => error task_name = params.fetch(:task_id) redirect_to(task_path(task_name), alert: error.) rescue Runner::EnqueuingError => error redirect_to(task_path(error.run.task_name), alert: error.) end |
#pause ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Updates a Run status to paused.
34 35 36 37 38 39 |
# File 'app/controllers/maintenance_tasks/runs_controller.rb', line 34 def pause @run.pause redirect_to(task_path(@run.task_name)) rescue ActiveRecord::RecordInvalid => error redirect_to(task_path(@run.task_name), alert: error.) end |
#resume ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Resumes a previously paused Run.
50 51 52 53 54 55 56 57 |
# File 'app/controllers/maintenance_tasks/runs_controller.rb', line 50 def resume Runner.resume(@run) redirect_to(task_path(@run.task_name)) rescue ActiveRecord::RecordInvalid => error redirect_to(task_path(@run.task_name), alert: error.) rescue Runner::EnqueuingError => error redirect_to(task_path(@run.task_name), alert: error.) end |