9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'app/jobs/ragdoll/generate_summary_job.rb', line 9
def perform(document_id)
document = Ragdoll::Document.find(document_id)
return unless document.content.present?
return if document.summary.present?
text_service = Ragdoll::TextGenerationService.new
summary = text_service.generate_summary(document.content)
document.update!(summary: summary) if summary.present?
rescue ActiveRecord::RecordNotFound
rescue StandardError => e
Rails.logger.error "Failed to generate summary for document #{document_id}: #{e.message}" if defined?(Rails)
raise e
end
|