diff --git a/app/controllers/nonprofits/imports_controller.rb b/app/controllers/nonprofits/imports_controller.rb index a5344a06..87f92d69 100644 --- a/app/controllers/nonprofits/imports_controller.rb +++ b/app/controllers/nonprofits/imports_controller.rb @@ -9,13 +9,7 @@ module Nonprofits # post /nonprofits/:nonprofit_id/imports def create render_json do - InsertImport.delay.from_csv_safe( - nonprofit_id: import_params[:nonprofit_id], - user_id: current_user.id, - user_email: current_user.email, - file_uri: import_params[:file_uri], - header_matches: import_params[:header_matches] - ) + ImportCreationJob.perform_later(import_params, current_user) end end diff --git a/app/jobs/import_creation_job.rb b/app/jobs/import_creation_job.rb new file mode 100644 index 00000000..97c24f0d --- /dev/null +++ b/app/jobs/import_creation_job.rb @@ -0,0 +1,13 @@ +class ImportCreationJob < ApplicationJob + queue_as :default + + def perform(import_params, current_user) + InsertImport.from_csv_safe( + nonprofit_id: import_params[:nonprofit_id], + user_id: current_user.id, + user_email: current_user.email, + file_uri: import_params[:file_uri], + header_matches: import_params[:header_matches] + ) + end +end