Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 
 

28 строки
649 B

  1. class ContentGenerationJob < ApplicationJob
  2. require 'docsplit'
  3. @document_id = nil
  4. queue_as :default
  5. after_perform :generate_tags
  6. def perform(document_id)
  7. @document_id = document_id
  8. document = Document.find(document_id)
  9. Docsplit.extract_text(document.doc.path, output: 'tmp/raw_content')
  10. file_path = 'tmp/raw_content/' + File.basename(document.doc.path, 'pdf') + 'txt'
  11. text = IO.read(file_path)
  12. content = document.build_content(text: text)
  13. content.save!
  14. File.delete(file_path) if File.exist?(file_path)
  15. end
  16. private
  17. def generate_tags
  18. TagGenerationJob.perform_now @document_id
  19. end
  20. end