Sha256: 6b83b5b7d0135feded63792c631953af0438ef7fceb34041740d3be99f379013

Contents?: true

Size: 716 Bytes

Versions: 4

Compression:

Stored size: 716 Bytes

Contents

# frozen_string_literal: true

# ImportDocumentJob class
class ImportDocumentJob < ApplicationJob
  queue_as :default

  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

4 entries across 4 versions & 1 rubygems

Version Path
geoblacklight_admin-0.3.0 app/jobs/import_document_job.rb
geoblacklight_admin-0.2.1 app/jobs/import_document_job.rb
geoblacklight_admin-0.1.0 app/jobs/import_document_job.rb
geoblacklight_admin-0.0.1 app/jobs/import_document_job.rb