importo 3.0.17 → 3.0.19

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 889fe30458aad6a71cd035c536ccf89a954bfd9876695312da33ed3721008ece
4
- data.tar.gz: 30bbe4ad60229d637580bbcdf5a272e8367caa800ab82bc9fcf73513914222fd
3
+ metadata.gz: 2e37a58ff77d3eae705e41d35a11505ab8c9e4a595c95f3df9697bcc96726a6b
4
+ data.tar.gz: 3436a1df14ac457d6eb3d62f70f87a7bd045481c144d12310ecb70a2e64be258
5
5
  SHA512:
6
- metadata.gz: 1199d4f8b28371c6885ac5de06b1dfaee325a229b514995a88ff00faec5e4bb7fc3ea70ea5c20d54893e53e2aa2bb431f560e699d0144b6917f48ff81af44a28
7
- data.tar.gz: ba7f56e0c96d24fbdc60ec9503a161ba356015b461ab5f6e961bf0b56e3252d26af091ebd8f83c49db6c02417adf13809982cf857067b89f233654777295582b
6
+ metadata.gz: f067df4453f21d32e6fa79addc463d33150c3e23bb53e9f9736a440af097dfec656af13ae1a83a208f759fea436f895367e2ab5730c4fc2d19ae306a38aa9a75
7
+ data.tar.gz: 2c8857c902b0f5db54e7aaef64c46c3b66a430fc74db79782a43ba6e3358529c934c5f4761ade1b8a6a2ec4f73d71c2345634c1f3a29d9565df4fc10ad73029c
@@ -8,10 +8,10 @@ module Importo
8
8
  @instance = Sidekiq::Batch.new
9
9
  end
10
10
 
11
- delegate :description=, :bid, to: :@instance
11
+ delegate :description=, :status, to: :@instance
12
12
 
13
13
  def on_success(job)
14
- @instance.on(:success, job.constantize, properties)
14
+ @instance.on(:complete, job.constantize, properties)
15
15
  end
16
16
 
17
17
  def add
@@ -132,17 +132,16 @@ module Importable
132
132
  batch.on_success("Importo::ImportJobCallback")
133
133
 
134
134
  batch.add do
135
- bid = batch.bid
136
135
  column_with_delay = columns.select { |k, v| v.delay.present? }
137
136
  loop_data_rows do |attributes, index|
138
137
  if column_with_delay.present?
139
- delay = column_with_delay.map do |k, v|
138
+ delay = column_with_delay.filter_map do |k, v|
140
139
  next unless attributes[k].present?
141
140
  v.delay.call(attributes[k])
142
- end.compact
141
+ end
143
142
  end
144
- Importo::ImportJob.set(wait_until: (delay.max * index).seconds.from_now).perform_async(JSON.dump(attributes), index, import.id, bid) if delay.present?
145
- Importo::ImportJob.perform_async(JSON.dump(attributes), index, import.id, bid) unless delay.present?
143
+ Importo::ImportJob.set(wait_until: (delay.max * index).seconds.from_now).perform_async(JSON.dump(attributes), index, import.id) if delay.present?
144
+ Importo::ImportJob.perform_async(JSON.dump(attributes), index, import.id) unless delay.present?
146
145
  end
147
146
  end
148
147
 
@@ -2,12 +2,18 @@ module Importo
2
2
  class ImportJobCallback
3
3
  include Rails.application.routes.url_helpers
4
4
 
5
- def on_success(_status, options)
5
+ def on_complete(_status, options)
6
6
  options = options.deep_stringify_keys
7
7
  import = Import.find(options["import_id"])
8
8
  if import.present?
9
- import.result.attach(io: import.importer.results_file, filename: import.importer.file_name("results"),
10
- content_type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
9
+ results_file = import.importer.results_file
10
+ if results_file.is_a?(StringIO)
11
+ import.result.attach(io: results_file, filename: import.importer.file_name("results"),
12
+ content_type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
13
+ else
14
+ import.result.attach(io: File.open(results_file), filename: import.importer.file_name("results"),
15
+ content_type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
16
+ end
11
17
 
12
18
  ActiveRecord::Base.uncached do
13
19
  import.result_message = I18n.t("importo.importers.result_message",
@@ -20,7 +20,7 @@ module Importo
20
20
  end
21
21
  end
22
22
 
23
- def perform(attributes, index, import_id, bid)
23
+ def perform(attributes, index, import_id)
24
24
  self.class.execute_row(attributes, index, import_id, false, bid)
25
25
  end
26
26
 
@@ -33,7 +33,7 @@ module Importo
33
33
  batch = Importo::SidekiqBatchAdapter.find(bid)
34
34
 
35
35
  if !import.completed? && import.can_complete? && batch.finished?
36
- ImportJobCallback.new.on_success(batch.status, {import_id: import_id})
36
+ ImportJobCallback.new.on_complete(batch.status, {import_id: import.id})
37
37
  end
38
38
  end
39
39
  end
@@ -111,6 +111,8 @@ module Importo
111
111
  private
112
112
 
113
113
  def schedule_import
114
+ # Since servitium isn't ActiveJob we can't implement a wait, this should be replaced
115
+ sleep(1)
114
116
  ImportService.perform_later(import: self)
115
117
  end
116
118
 
@@ -1,4 +1,4 @@
1
- # frozen_string_literal: true
1
+ # frozen_string_literal: true-
2
2
 
3
3
  require "axlsx"
4
4
  require "roo/excelx"
@@ -30,7 +30,7 @@ module Importo
30
30
  import.save!
31
31
 
32
32
  ImportService.perform(import: import)
33
- ImportJobCallback.new.on_success({import_id: import.id})
33
+ ImportJobCallback.new.on_complete("success", {import_id: import.id})
34
34
  import
35
35
  end
36
36
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Importo
4
- VERSION = "3.0.17"
4
+ VERSION = "3.0.19"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: importo
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.17
4
+ version: 3.0.19
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andre Meij
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2024-10-01 00:00:00.000000000 Z
12
+ date: 2024-10-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: caxlsx