ntq_excelsior_engine 1.0.2 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1c60af2d74b7e92d3efb1959fda614c639c99a6b89050fdaad29ef4501a60efb
4
- data.tar.gz: 82d4cefad83ee6be3fb490232f13ea1a764c96438b8f68732bb88c3ec08ba169
3
+ metadata.gz: 149fb970b09822b3700a0feea155925cc053758cad0293d60511cefd33d3b774
4
+ data.tar.gz: 871c628686c6ead3c67ffd5a86d3c0596e87d56796671c272f43c85ee4a4b45f
5
5
  SHA512:
6
- metadata.gz: d6abed7bf3192e4eda55b371a572b233581c4b89fd66844be65bb7a568867a48e7803f0c68309349b69829445b627948987699d44ca1237a28794a1b53ed6269
7
- data.tar.gz: 05ff52c2b51760f294fc7485c52c2ac36e9b74557174ab7c378203d3fb9f4c054235411a14c1dff0621ca037431b626a017b97bb59ae90fde9d42690b8cd89bc
6
+ metadata.gz: 97f6391929e87d982d1c10b71335d75600b84851bcc2823a5e4c8fd63b239cfb7054d5a876b93dc277b832d0b8a1fb7ddd2115d946e37502b9e181b5b30be26e
7
+ data.tar.gz: 165b172c9ad7d47a1aff11a0a2d66da3ea161462f3fc2de5c142bc9759a512697d89f64dae316543877ff9a86c668834ad06c1a0a06559831b21ac30809adfcd
@@ -1,14 +1,13 @@
1
1
  module NtqExcelsiorEngine
2
2
  class Imports::LoadLines
3
3
  include Interactor
4
-
4
+
5
5
  around do |interactor|
6
- if context.actions && context.actions.include?("load") && context.import && context.importer
7
- interactor.call
8
- end
6
+ interactor.call if context.actions && context.actions.include?('load') && context.import && context.importer
9
7
  end
10
-
8
+
11
9
  def call
10
+ sleep NtqExcelsiorEngine.delay_before_import if NtqExcelsiorEngine.delay_before_import > 0
12
11
  import = context.import
13
12
  importer = context.importer.new
14
13
  begin
@@ -27,11 +26,12 @@ module NtqExcelsiorEngine
27
26
  import.temp_file.unlink
28
27
  rescue Roo::HeaderRowNotFoundError => e
29
28
  import.update(state: 'error', error_message: 'header_not_found', backtrace: e.message)
30
- rescue => e
29
+ rescue StandardError => e
31
30
  raise e if NtqExcelsiorEngine.debug
31
+
32
32
  Appsignal.send_error(e)
33
33
  import.update(state: 'error', error_message: e.message, backtrace: e.backtrace.join('\n'))
34
34
  end
35
35
  end
36
36
  end
37
- end
37
+ end
@@ -1,11 +1,11 @@
1
1
  module NtqExcelsiorEngine
2
2
  class Import < ::ApplicationRecord
3
-
4
- self.table_name = "excelsior_imports"
5
-
3
+ self.table_name = 'excelsior_imports'
4
+
6
5
  attr_accessor :async
7
6
 
8
- enum state: { pending: 'pending', buffering: 'buffering', buffered: 'buffered', imported: 'imported', error: 'error', importing: 'importing', checking: 'checking', checked: 'checked' }
7
+ enum state: { pending: 'pending', buffering: 'buffering', buffered: 'buffered', imported: 'imported',
8
+ error: 'error', importing: 'importing', checking: 'checking', checked: 'checked' }
9
9
 
10
10
  serialize :options, Hash
11
11
  serialize :headers, Hash
@@ -21,7 +21,6 @@ module NtqExcelsiorEngine
21
21
  validates :import_type, presence: true
22
22
  validates :import_type, inclusion: { in: NtqExcelsiorEngine.importers.keys.map(&:to_s) }, on: :create
23
23
 
24
-
25
24
  def temp_file
26
25
  return @tmp if @tmp
27
26
 
@@ -37,10 +36,9 @@ module NtqExcelsiorEngine
37
36
  end
38
37
 
39
38
  def process_import!(actions: NtqExcelsiorEngine.actions_on_create.map(&:to_s))
40
- if async || (async.nil? && NtqExcelsiorEngine.async)
41
- job_id = NtqExcelsiorEngine::ProcessImportJob.perform_async(id, actions.join(','))
42
- p "ASYNC #{job_id}"
43
- end
39
+ return unless async || (async.nil? && NtqExcelsiorEngine.async)
40
+
41
+ job_id = NtqExcelsiorEngine::ProcessImportJob.perform_async(id, actions.join(','))
44
42
  end
45
43
  end
46
44
  end
@@ -1,3 +1,3 @@
1
1
  module NtqExcelsiorEngine
2
- VERSION = "1.0.2"
2
+ VERSION = '1.0.3'
3
3
  end
@@ -12,6 +12,9 @@ module NtqExcelsiorEngine
12
12
  mattr_accessor :async
13
13
  @@async = false
14
14
 
15
+ mattr_accessor :delay_before_import
16
+ @@delay_before_import = 0
17
+
15
18
  mattr_accessor :actions_on_create
16
19
  @@actions_on_create = [:load, :check, :import]
17
20
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ntq_excelsior_engine
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin