Class: BulkActionRunJob

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

Overview

BulkActionRunJob

Instance Method Summary collapse

Instance Method Details

#perform(bulk_action) ⇒ Object



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

def perform(bulk_action)
  action = case bulk_action.field_name
  when "Publication State"
    logger.debug("BulkAction: Update Publication Status")
    :update_publication_status
  when "Delete"
    logger.debug("BulkAction: Delete")
    :update_delete
  else
    :update_field_value
  end

  bulk_action.documents.each do |doc|
    BulkActionRunDocumentJob.perform_later(action, doc, bulk_action.field_name, bulk_action.field_value)
    doc.state_machine.transition_to!(:queued)
  end

  # Capture State
  bulk_action.state_machine.transition_to!(:queued)
end