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 |
# File 'app/controllers/kuroko2/job_instances_controller.rb', line 11 def create creation_params = { launched_by: current_user.name } if params[:job_definition].present? creation_params.merge!(params.require(:job_definition).permit(:script).to_h.symbolize_keys) end @instance = @definition.create_instance(**creation_params) redirect_to job_definition_job_instance_path(@definition, @instance) end |
#destroy ⇒ Object
32 33 34 35 36 37 38 |
# File 'app/controllers/kuroko2/job_instances_controller.rb', line 32 def destroy if @instance.cancelable? ActiveRecord::Base.transaction { @instance.cancel(by: current_user.name) } end redirect_to job_definition_job_instance_path(@definition, @instance) end |
#force_destroy ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'app/controllers/kuroko2/job_instances_controller.rb', line 40 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(by: current_user.name) 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
21 22 23 24 25 26 27 28 29 30 |
# File 'app/controllers/kuroko2/job_instances_controller.rb', line 21 def show @logs = @instance.logs.order(:id) @tokens = @instance.tokens.order(:id) if params[:mode] == :naked render partial: 'instance', layout: false else # render end end |
#working ⇒ Object
57 58 59 |
# File 'app/controllers/kuroko2/job_instances_controller.rb', line 57 def working @instances = Kuroko2::JobInstance.working.order(id: :desc).joins(job_definition: :admins).includes(job_definition: :admins) end |