Class: Kuroko2::JobInstancesController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Kuroko2::JobInstancesController
- Defined in:
- app/controllers/kuroko2/job_instances_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #force_destroy ⇒ Object
- #index ⇒ Object
- #show ⇒ Object
- #working ⇒ Object
Methods inherited from ApplicationController
Instance Method Details
#create ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'app/controllers/kuroko2/job_instances_controller.rb', line 11 def create if params[:job_definition].present? @instance = @definition.job_instances.create(params.require(:job_definition).permit(:script)) else @instance = @definition.job_instances.create end if @instance @instance.logs.info("Launched by #{current_user.name}.") redirect_to job_definition_job_instance_path(@definition, @instance) else raise HTTP::BadRequest end end |
#destroy ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 |
# File 'app/controllers/kuroko2/job_instances_controller.rb', line 38 def destroy if @instance.cancelable? ActiveRecord::Base.transaction { @instance.cancel } = "This job was canceled by #{current_user.name}." @instance.logs.warn() Kuroko2.logger.warn() end redirect_to job_definition_job_instance_path(@definition, @instance) end |
#force_destroy ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'app/controllers/kuroko2/job_instances_controller.rb', line 50 def force_destroy ActiveRecord::Base.transaction do @instance.executions.each do |execution| execution = Kuroko2::Worker.executing(execution.id) execution.update_column(:execution_id, nil) if execution end @instance.cancel end = "Force canceled by #{current_user.name}." @instance.logs.warn() Kuroko2.logger.warn() redirect_to job_definition_job_instance_path(@definition, @instance) end |
#index ⇒ Object
5 6 7 8 9 |
# File 'app/controllers/kuroko2/job_instances_controller.rb', line 5 def index @instances = @definition.job_instances.page(page_params[:page]) render layout: false end |
#show ⇒ Object
27 28 29 30 31 32 33 34 35 36 |
# File 'app/controllers/kuroko2/job_instances_controller.rb', line 27 def show @logs = @instance.logs @tokens = @instance.tokens if params[:mode] == :naked render partial: 'instance', layout: false else # render end end |
#working ⇒ Object
67 68 69 |
# File 'app/controllers/kuroko2/job_instances_controller.rb', line 67 def working @instances = Kuroko2::JobInstance.working.order(id: :desc).joins(job_definition: :admins).includes(job_definition: :admins) end |