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
|
# File 'app/controllers/data_migration/imports_controller.rb', line 13
def create
authorize @migration_plan, :execute?
unless params[:archive_file].present?
redirect_to "/data_migration/migration_plans/#{@migration_plan.id}/import/new",
alert: 'Please select a file to upload.'
return
end
uploaded_file = params[:archive_file]
file_path = save_uploaded_file(uploaded_file)
filter_params = params[:filter_params].present? ? params[:filter_params] : {}
execution = MigrationExecution.create!(
migration_plan: @migration_plan,
user: current_user,
execution_type: :import,
status: :pending,
file_path: file_path,
filter_params: filter_params
)
ImportJob.perform_later(execution.id)
redirect_to "/data_migration/migration_executions/#{execution.id}",
notice: 'Import started. You will be notified when it completes.'
end
|