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 +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/app/models/importo/import.rb +2 -0
- 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: 2e37a58ff77d3eae705e41d35a11505ab8c9e4a595c95f3df9697bcc96726a6b
|
4
|
+
data.tar.gz: 3436a1df14ac457d6eb3d62f70f87a7bd045481c144d12310ecb70a2e64be258
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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=, :
|
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.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-
|
12
|
+
date: 2024-10-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: caxlsx
|