Sha256: e589c3b40e3363404f7bdad21df60c13b3bcb3113b281846e6a9f421612208ae

Contents?: true

Size: 649 Bytes

Versions: 6

Compression:

Stored size: 649 Bytes

Contents

# frozen_string_literal: true

# ImportDocumentJob class
class ImportDocumentJob < ApplicationJob
  queue_as :priority

  def perform(import_document)
    document = Document.find_or_create_by(friendlier_id: import_document.friendlier_id)

    # Set the geom
    document.set_geometry

    if document.update(import_document.to_hash)
      import_document.state_machine.transition_to!(:success)
    else
      import_document.state_machine.transition_to!(:failed, "Failed - #{document.errors.inspect}")
    end
  rescue => e
    logger.debug("Error: #{e}")
    import_document.state_machine.transition_to!(:failed, "Error - #{e.inspect}")
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
geoblacklight_admin-0.7.0 app/jobs/import_document_job.rb
geoblacklight_admin-0.6.3 app/jobs/import_document_job.rb
geoblacklight_admin-0.6.2 app/jobs/import_document_job.rb
geoblacklight_admin-0.6.1 app/jobs/import_document_job.rb
geoblacklight_admin-0.6.0 app/jobs/import_document_job.rb
geoblacklight_admin-0.5.1 app/jobs/import_document_job.rb