Class: CollavreNotion::NotionExportJob

Inherits:
ApplicationJob
  • Object
show all
Defined in:
app/jobs/collavre_notion/notion_export_job.rb

Instance Method Summary collapse

Instance Method Details

#perform(creative, notion_account, parent_page_id = nil) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/jobs/collavre_notion/notion_export_job.rb', line 5

def perform(creative, , parent_page_id = nil)
  service = CollavreNotion::NotionService.new(user: .user)

  begin
    # Export the creative tree to Notion
    link = service.sync_creative(creative, parent_page_id: parent_page_id)

    Rails.logger.info("Successfully exported creative #{creative.id} to Notion page #{link.page_id}")

    # You could add broadcast/notification logic here if needed
    # ActionCable.server.broadcast("user_#{notion_account.user.id}", {
    #   type: 'notion_export_complete',
    #   creative_id: creative.id,
    #   page_url: link.page_url
    # })
  rescue NotionError => e
    Rails.logger.error("Notion export failed for creative #{creative.id}: #{e.message}")
    raise e
  rescue StandardError => e
    Rails.logger.error("Unexpected error during Notion export for creative #{creative.id}: #{e.message}")
    raise e
  end
end