app/controllers/naf/historical_jobs_controller.rb in naf-2.0.4 vs app/controllers/naf/historical_jobs_controller.rb in naf-2.1.0
- old
+ new
@@ -39,37 +39,44 @@
@historical_job = Naf::HistoricalJob.find(params[:id])
@logical_job = Logical::Naf::Job.new(@historical_job)
end
def new
+ @historical_job = Naf::HistoricalJob.new
end
def create
@historical_job = Naf::HistoricalJob.new(params[:historical_job])
- if params[:historical_job][:application_id] && app = Naf::Application.find(params[:historical_job][:application_id])
- if schedule = app.application_schedule
- @historical_job = Logical::Naf::JobCreator.new.queue_application_schedule(schedule)
+ if params[:historical_job][:application_id] &&
+ app = Naf::Application.find(params[:historical_job][:application_id])
+
+ if schedule = app.application_schedules.first
+ @historical_job = ::Logical::Naf::ConstructionZone::Boss.new.enqueue_application_schedule(schedule)
if @historical_job.blank?
- render json: { success: false,
- title: ::Naf::Application.find_by_id(params[:historical_job][:application_id]).title }.to_json
+ render json: {
+ success: false,
+ title: ::Naf::Application.find_by_id(params[:historical_job][:application_id]).title
+ }.to_json
return
end
else
@historical_job.command = app.command
@historical_job.application_type_id = app.application_type_id
- @historical_job.application_run_group_restriction_id = Naf::ApplicationRunGroupRestriction.no_limit.id
+ @historical_job.application_run_group_restriction_id =
+ Naf::ApplicationRunGroupRestriction.no_limit.id
@queued_job = ::Naf::QueuedJob.new
end
else
@queued_job = ::Naf::QueuedJob.new
end
if @queued_job.present?
@queued_job.application_type_id = @historical_job.application_type_id
@queued_job.command = @historical_job.command
- @queued_job.application_run_group_restriction_id = @historical_job.application_run_group_restriction_id
+ @queued_job.application_run_group_restriction_id =
+ @historical_job.application_run_group_restriction_id
@queued_job.application_run_group_name = @historical_job.application_run_group_name
@queued_job.application_run_group_limit = @historical_job.application_run_group_limit
@queued_job.priority = @historical_job.priority
end
@@ -121,10 +128,13 @@
@historical_job.update_attributes(request_to_terminate: true)
end
end
format.html do
- redirect_to(@historical_job, notice: "Job '#{@historical_job.command}' was successfully updated.")
+ redirect_to(
+ @historical_job,
+ notice: "Job '#{@historical_job.command}' was successfully updated."
+ )
end
format.json do
render json: { success: true,
title: @historical_job.title,
command: @historical_job.command }.to_json