importo 3.0.23 → 3.0.24
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/controllers/importo/imports_controller.rb +3 -3
- data/app/importers/concerns/importable.rb +2 -2
- data/app/importers/importo/import_job_callback.rb +2 -2
- data/app/jobs/importo/import_job.rb +24 -11
- data/app/views/importo/imports/new.html.slim +2 -2
- data/app/views/importo/imports/preview.html.slim +2 -3
- data/config/locales/en.yml +3 -2
- data/lib/importo/adapters/sidekiq_batch_adapter.rb +5 -3
- 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: ab14d9e5565f7313de5ff1453e203bbf3f64670eb12d0f1f76c0f7149f747ee7
|
|
4
|
+
data.tar.gz: d9ab88a3625c778c7379def02f3f1680247c4228697e90fdd8d5f1f3599af954
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 41719578949eb007165adfac5c64ce78ce301dc12283cf6b66b29cf075bc3cab2ccd53c57b25bee71b88df7795a4b96285e1ce168fc2fa93b15f52e02215e892
|
|
7
|
+
data.tar.gz: 4c45ad49b70c9199c9ea9d7cc6766b1b937851fd730df733dc0985e8db00abbb89fcae86639022ecd7c69272de33ebb304870996b75831924a57adf230971127
|
|
@@ -35,11 +35,11 @@ module Importo
|
|
|
35
35
|
end
|
|
36
36
|
@import = Import.new(import_params.merge(locale: I18n.locale,
|
|
37
37
|
importo_ownable: Importo.config.current_import_owner.call))
|
|
38
|
-
if params["commit"] == "
|
|
38
|
+
if params["commit"] == "Upload" && @import.valid? && @import.save!
|
|
39
39
|
@import.confirm!
|
|
40
40
|
@import.schedule!
|
|
41
41
|
redirect_to importo.new_import_path(params[:kind] || @import.kind)
|
|
42
|
-
elsif params["commit"] == "
|
|
42
|
+
elsif params["commit"] == "Preview" && @import.valid?
|
|
43
43
|
@import.save!
|
|
44
44
|
redirect_to action: :preview, id: @import.id, kind: @import.kind
|
|
45
45
|
else
|
|
@@ -52,7 +52,7 @@ module Importo
|
|
|
52
52
|
@import = Import.find(params[:id])
|
|
53
53
|
@import.original.purge if @import.concept?
|
|
54
54
|
Signum.error(Current.user, text: t('.flash.cancel', id: @import.id))
|
|
55
|
-
|
|
55
|
+
@import.destroy!
|
|
56
56
|
redirect_to action: :new, kind: @import.kind
|
|
57
57
|
end
|
|
58
58
|
|
|
@@ -144,8 +144,8 @@ module Importable
|
|
|
144
144
|
v.delay.call(attributes[k])
|
|
145
145
|
end
|
|
146
146
|
end
|
|
147
|
-
Importo::ImportJob.set(wait_until: (delay.max * index).seconds.from_now).
|
|
148
|
-
Importo::ImportJob.
|
|
147
|
+
Importo::ImportJob.set(wait_until: (delay.max * index).seconds.from_now).perform_async(JSON.dump(attributes), index, import.id) if delay.present?
|
|
148
|
+
Importo::ImportJob.perform_async(JSON.dump(attributes), index, import.id) unless delay.present?
|
|
149
149
|
end
|
|
150
150
|
end
|
|
151
151
|
|
|
@@ -3,8 +3,8 @@ module Importo
|
|
|
3
3
|
include Sidekiq::Batch::Callback
|
|
4
4
|
include Rails.application.routes.url_helpers
|
|
5
5
|
|
|
6
|
-
def perform(batch,
|
|
7
|
-
import = Import.find(
|
|
6
|
+
def perform(batch, import_id)
|
|
7
|
+
import = Import.find(import_id)
|
|
8
8
|
complete_import(import)
|
|
9
9
|
end
|
|
10
10
|
|
|
@@ -1,14 +1,27 @@
|
|
|
1
1
|
module Importo
|
|
2
|
-
|
|
2
|
+
base_class =
|
|
3
|
+
if Importo.config.batch_adapter == Importo::SidekiqBatchAdapter
|
|
4
|
+
Object
|
|
5
|
+
else
|
|
6
|
+
ApplicationJob
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
class ImportJob < base_class
|
|
10
|
+
|
|
3
11
|
# No options here, gets added from the adapter
|
|
4
|
-
queue_as Importo.config.queue_name
|
|
5
|
-
include GoodJob::ActiveJobExtensions::Batches
|
|
6
12
|
|
|
7
13
|
def perform(attributes, index, import_id)
|
|
8
|
-
|
|
14
|
+
batch_id = if defined?(bid)
|
|
15
|
+
bid
|
|
16
|
+
else
|
|
17
|
+
batch.id
|
|
18
|
+
end
|
|
19
|
+
batch
|
|
20
|
+
|
|
21
|
+
self.class.execute_row(attributes, index, import_id, false, batch_id)
|
|
9
22
|
end
|
|
10
23
|
|
|
11
|
-
def self.execute_row(attributes, index, import_id, last_attempt)
|
|
24
|
+
def self.execute_row(attributes, index, import_id, last_attempt, bid)
|
|
12
25
|
attributes = JSON.load(attributes).deep_symbolize_keys if attributes.is_a?(String)
|
|
13
26
|
|
|
14
27
|
import = Import.find(import_id)
|
|
@@ -18,13 +31,13 @@ module Importo
|
|
|
18
31
|
# - Sidekiq calls on_complete callback when all jobs ran at least once.
|
|
19
32
|
# - GoodJob calls on_complete callback when all jobs are done (including retries).
|
|
20
33
|
# i.e. this logic is only needed for sidekiq
|
|
21
|
-
|
|
22
|
-
|
|
34
|
+
if Importo.config.batch_adapter == Importo::SidekiqBatchAdapter
|
|
35
|
+
batch = Importo::SidekiqBatchAdapter.find(bid)
|
|
23
36
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
37
|
+
if !import.completed? && import.can_complete? && batch.finished?
|
|
38
|
+
ImportJobCallback.perform_now(batch, import.id)
|
|
39
|
+
end
|
|
40
|
+
end
|
|
28
41
|
end
|
|
29
42
|
end
|
|
30
43
|
end
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
= f.input :kind, as: :hidden
|
|
5
5
|
= sts.card :"importo_imports #{@import.kind}", title: t('.title'), icon: 'fad fa-file-spreadsheet' do |card|
|
|
6
6
|
- card.with_action
|
|
7
|
-
= f.button '
|
|
7
|
+
= f.button 'Preview', value: 'Preview', class: 'button secondary'
|
|
8
8
|
- card.with_action
|
|
9
|
-
= f.submit nil, value: '
|
|
9
|
+
= f.submit nil, value: 'Upload'
|
|
10
10
|
|
|
11
11
|
.grid.grid-cols-12.gap-4
|
|
12
12
|
.col-span-12
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
= sts.form_with(model: false, url: upload_import_path) do |f|
|
|
2
2
|
= sts.card :"importo_imports #{@import.kind}", title: t('.title', kind: @import&.kind.capitalize), icon: 'fad fa-file-spreadsheet' do |card|
|
|
3
3
|
- card.with_action
|
|
4
|
-
|
|
5
|
-
=
|
|
6
|
-
= link_to(t('.cancel'), cancel_import_path(@import), method: :post, class: 'button')
|
|
4
|
+
= f.submit 'Upload', value: 'Upload'
|
|
5
|
+
= link_to(t('.back'), cancel_import_path(@import), data: { "turbo-method" => :post}, class: 'button')
|
|
7
6
|
.px-4.sm:px-6.lg:px-8
|
|
8
7
|
/ .sm:flex.sm:items-center
|
|
9
8
|
/ .sm:flex-auto
|
data/config/locales/en.yml
CHANGED
|
@@ -15,7 +15,8 @@ en:
|
|
|
15
15
|
example: Example
|
|
16
16
|
imports:
|
|
17
17
|
cancel:
|
|
18
|
-
|
|
18
|
+
flash:
|
|
19
|
+
cancel: "Import canceled for id %{id}, Redirecting to new"
|
|
19
20
|
index:
|
|
20
21
|
title: Import results
|
|
21
22
|
card:
|
|
@@ -43,7 +44,7 @@ en:
|
|
|
43
44
|
preview:
|
|
44
45
|
no_file: Import failed, please upload valid file.
|
|
45
46
|
title: "%{kind} Import Preview"
|
|
46
|
-
|
|
47
|
+
back: Back
|
|
47
48
|
upload:
|
|
48
49
|
flash:
|
|
49
50
|
no_file: Import failed, please upload a file.
|
|
@@ -8,7 +8,6 @@ if !defined?(Sidekiq::Batch)
|
|
|
8
8
|
end
|
|
9
9
|
end
|
|
10
10
|
|
|
11
|
-
require_relative "../../../app/jobs/importo/import_job"
|
|
12
11
|
|
|
13
12
|
module Importo
|
|
14
13
|
class SidekiqBatchAdapter
|
|
@@ -75,5 +74,8 @@ module Importo
|
|
|
75
74
|
end
|
|
76
75
|
end
|
|
77
76
|
|
|
78
|
-
|
|
79
|
-
|
|
77
|
+
require_relative "../../../app/jobs/importo/import_job"
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
Importo::ImportJob.send(:include, Sidekiq::Job)
|
|
81
|
+
Importo::ImportJob.send(:include, Importo::SidekiqBatchAdapter::ImportJobIncludes)
|
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.24
|
|
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: 2025-
|
|
12
|
+
date: 2025-12-09 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: caxlsx
|