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



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'app/jobs/bulk_action_run_job.rb', line 12

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
  when "Harvest Thumbnails"
    logger.debug("BulkAction: Harvest Thumbnails")
    :harvest_thumbnails
  when "Delete Thumbnails"
    logger.debug("BulkAction: Delete Thumbnails")
    :delete_thumbnails
  else
    :update_field_value
  end

  bulk_action.documents.each do |doc|
    BulkActionRunDocumentJob.perform_later(action, doc, bulk_action.field_name, bulk_action.field_value)
  end

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