12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
# File 'app/controllers/data_migration/exports_controller.rb', line 12
def create
authorize @migration_plan, :execute?
required_params =
provided_params = if params[:filter_params].present? && required_params.any?
params.require(:filter_params).permit(*required_params.keys)
else
{}
end
missing_params = required_params.keys.select do |param|
provided_params[param].blank?
end
if missing_params.any?
flash[:alert] = "Please provide values for: #{missing_params.join(', ')}"
@filter_params = required_params
render :new and return
end
execution = MigrationExecution.create!(
migration_plan: @migration_plan,
user: current_user,
execution_type: :export,
status: :pending,
filter_params: provided_params.to_h
)
ExportJob.perform_later(execution.id)
redirect_to "/data_migration/migration_executions/#{execution.id}",
notice: 'Export started. You will be notified when it completes.'
end
|