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 +4 -4
- data/app/adapters/importo/sidekiq_batch_adapter.rb +2 -2
- data/app/importers/concerns/importable.rb +4 -5
- data/app/importers/importo/import_job_callback.rb +9 -3
- data/app/jobs/importo/import_job.rb +2 -2
- data/lib/importo/test_helpers.rb +2 -2
- data/lib/importo/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6377f43dbbb4b09f3700ceb910fad844598c0197c5f35857c2cd712cf37cdd4b
|
4
|
+
data.tar.gz: a22342e284e1df6b973920d4404c3641eba58ef0e47a79dd3ccf66b2db6e3b23
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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=, :
|
11
|
+
delegate :description=, :status, to: :@instance
|
12
12
|
|
13
13
|
def on_success(job)
|
14
|
-
@instance.on(:
|
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.
|
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
|
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
|
145
|
-
Importo::ImportJob.perform_async(JSON.dump(attributes), index, import.id
|
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
|
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
|
-
|
10
|
-
|
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
|
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.
|
36
|
+
ImportJobCallback.new.on_complete(batch.status, {import_id: import.id})
|
37
37
|
end
|
38
38
|
end
|
39
39
|
end
|
data/lib/importo/test_helpers.rb
CHANGED
@@ -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.
|
33
|
+
ImportJobCallback.new.on_complete("success", {import_id: import.id})
|
34
34
|
import
|
35
35
|
end
|
36
36
|
end
|
data/lib/importo/version.rb
CHANGED
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.
|
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-
|
12
|
+
date: 2024-10-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: caxlsx
|