Class: Publication::MarkdownExtractionHandler

Inherits:
ApplicationJob
  • Object
show all
Includes:
RailsEventStore::AsyncHandler
Defined in:
app/subscribers/publication/markdown_extraction_handler.rb

Overview

Async handler for Events::PublicationPdfChanged.

Queues UploadMarkdownExtractionWorker for the publication's literature
upload whenever its PDF is linked or replaced, so the document's layout-aware
Markdown (spec tables included) is pre-extracted and cached on
+uploads.extracted_markdown+ — ready for Sunny's +extract_document+ tool and
unattended jobs without an inline docling round-trip.

Sibling of VisionAnalysisHandler, which reacts to the same
event with Claude vision analysis.

Instance Method Summary collapse

Instance Method Details

#perform(event) ⇒ Object



19
20
21
22
23
24
25
26
27
28
# File 'app/subscribers/publication/markdown_extraction_handler.rb', line 19

def perform(event)
  item = Item.find_by(id: event.data[:item_id])
  return unless item&.is_publication? && item.literature_id

  Rails.logger.info "[Publication::MarkdownExtractionHandler] Queuing markdown extraction for Publication #{item.id} (upload #{item.literature_id})"
  UploadMarkdownExtractionWorker.perform_async(item.literature_id, { 'force' => true })
rescue StandardError => e
  ErrorReporting.error(e)
  raise
end