Add ImportCreationJob

This commit is contained in:
Eric Schultz 2019-11-07 15:16:21 -06:00
parent dd30aa3d59
commit 9c9033f2d3
2 changed files with 14 additions and 7 deletions

View file

@ -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

View file

@ -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