Sha256: 874f12c23fc25c962a7b9eaeff1109e9c1d9c03dd71f208262d9a573a4d077c1

Contents?: true

Size: 717 Bytes

Versions: 6

Compression:

Stored size: 717 Bytes

Contents

# frozen_string_literal: true

# ImportDocumentJob class
class ImportDocumentJob < ApplicationJob
  queue_as :priority

  def perform(import_document)
    # @TODO: Check for friendlier_id or raise error
    document = Document.where(
      friendlier_id: import_document.friendlier_id
    ).first_or_create

    # 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.5.0 app/jobs/import_document_job.rb
geoblacklight_admin-0.4.2 app/jobs/import_document_job.rb
geoblacklight_admin-0.4.1 app/jobs/import_document_job.rb
geoblacklight_admin-0.4.0 app/jobs/import_document_job.rb
geoblacklight_admin-0.3.2 app/jobs/import_document_job.rb
geoblacklight_admin-0.3.1 app/jobs/import_document_job.rb