importo 3.0.17 → 3.0.18

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: 889fe30458aad6a71cd035c536ccf89a954bfd9876695312da33ed3721008ece
4
- data.tar.gz: 30bbe4ad60229d637580bbcdf5a272e8367caa800ab82bc9fcf73513914222fd
3
+ metadata.gz: 6377f43dbbb4b09f3700ceb910fad844598c0197c5f35857c2cd712cf37cdd4b
4
+ data.tar.gz: a22342e284e1df6b973920d4404c3641eba58ef0e47a79dd3ccf66b2db6e3b23
5
5
  SHA512:
6
- metadata.gz: 1199d4f8b28371c6885ac5de06b1dfaee325a229b514995a88ff00faec5e4bb7fc3ea70ea5c20d54893e53e2aa2bb431f560e699d0144b6917f48ff81af44a28
7
- data.tar.gz: ba7f56e0c96d24fbdc60ec9503a161ba356015b461ab5f6e961bf0b56e3252d26af091ebd8f83c49db6c02417adf13809982cf857067b89f233654777295582b
6
+ metadata.gz: 5fd684e69696971df33154b2e4554566ba1609869139863ff0b104dd4cad6ba322f89f0a13f2f8170c505c8befb68cc3a6460ecab88bfa98782a3b0661ce7596
7
+ data.tar.gz: 1d7cd156345cf52bd9ac0dd348f9057f00baf3d84312d6068b851f4bb62631cbb1c9a75b9fc11cdc43c683500d941e99ca7816f650839cf5df37937fd85c5eae
@@ -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
@@ -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.18"
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.18
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