Class: GeoblacklightAdmin::DeleteThumbnailJob

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

Overview

A job to delete the thumbnail associated with a Solr document.

This job is enqueued with a priority queue and can optionally handle a bad document ID to transition its state.

Instance Method Summary collapse

Instance Method Details

#perform(solr_document_id, bad_id = nil, queue = :priority) ⇒ Object

Performs the job to delete a thumbnail.

If the document has a thumbnail, it will be destroyed. If a bad_id is provided, it will transition the state of the BulkActionDocument to :success.

Parameters:

  • solr_document_id (String)

    the ID of the Solr document

  • bad_id (String, nil) (defaults to: nil)

    optional ID of a bad document to transition

  • queue (Symbol) (defaults to: :priority)

    the queue to use, defaults to :priority



28
29
30
31
32
33
34
# File 'app/jobs/geoblacklight_admin/delete_thumbnail_job.rb', line 28

def perform(solr_document_id, bad_id = nil, queue = :priority)
  document = Document.find_by_friendlier_id(solr_document_id)
  if document.thumbnail.present?
    document.thumbnail.destroy!
  end
  BulkActionDocument.find(bad_id).state_machine.transition_to!(:success) if bad_id.present?
end