Class: Railspress::ImportPostsJob

Inherits:
ApplicationJob show all
Defined in:
app/jobs/railspress/import_posts_job.rb

Instance Method Summary collapse

Instance Method Details

#perform(import_id, file_paths) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'app/jobs/railspress/import_posts_job.rb', line 5

def perform(import_id, file_paths)
  import = Import.find(import_id)
  paths = Array(file_paths)

  import.mark_processing!

  begin
    paths.each do |file_path|
      processor = PostImportProcessor.new(import: import, file_path: file_path)
      processor.process_file(file_path)
    end
  ensure
    finalize_import(import)
    cleanup_uploaded_files(paths)
  end
end