Class: BulkActionRunDocumentJob

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

Overview

BulkActionRunDocumentJob

Instance Method Summary collapse

Instance Method Details

#perform(action, doc, field_name, field_value) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/jobs/bulk_action_run_document_job.rb', line 7

def perform(action, doc, field_name, field_value)
  case action
  when :update_publication_status
    update_publication_status(doc, field_value)
  when :update_delete
    update_delete(doc, field_value)
  when :harvest_thumbnails
    GeoblacklightAdmin::StoreImageJob.perform_later(doc.friendlier_id, doc.id, :priority)
  when :delete_thumbnails
    GeoblacklightAdmin::DeleteThumbnailJob.perform_later(doc.friendlier_id, doc.id, :priority)
  else
    # @TODO: Field Level changes
    logger.debug("@TODO - #{field_name} => #{field_value}")
  end
end

#update_delete(doc, field_value) ⇒ Object



31
32
33
34
35
36
37
# File 'app/jobs/bulk_action_run_document_job.rb', line 31

def update_delete(doc, field_value)
  document = Document.find_by!(friendlier_id: doc.friendlier_id)

  logger.debug("Update Delete - #{document.friendlier_id} => #{field_value}")

  document.destroy
end

#update_publication_status(doc, field_value) ⇒ Object



23
24
25
26
27
28
29
# File 'app/jobs/bulk_action_run_document_job.rb', line 23

def update_publication_status(doc, field_value)
  document = Document.find_by!(friendlier_id: doc.friendlier_id)

  logger.debug("Update PubStatus - #{document.friendlier_id} => #{field_value}")

  document.update!(publication_state: field_value.to_sym)
end