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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cd095c43d38bb324dea0b158ebe7743bd84630c526b755fc7b031e761fff8e91
4
- data.tar.gz: 772c031fe4446ce6db81e22c90f57ae9fb1dbfe1cbadd8ee62e0500fd3fe7a4e
3
+ metadata.gz: ab14d9e5565f7313de5ff1453e203bbf3f64670eb12d0f1f76c0f7149f747ee7
4
+ data.tar.gz: d9ab88a3625c778c7379def02f3f1680247c4228697e90fdd8d5f1f3599af954
5
5
  SHA512:
6
- metadata.gz: ffc02a4f1a09ad49a624206c615cfcd44a81dd489c28d7c7cdbf6780b451c786e5fde236503585cbf864faaa3e870781de5286b64e10dad21d53d50d1b8e75e5
7
- data.tar.gz: 75c6b5d26d837b23e5c7ac49514007121346dfb6ef1a7978e80a5105ebe41c666daf986a44c20fe3484bfefddc9d126d0fdad07e379036ccad214a4ca6aec243
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"] == "upload" && @import.valid? && @import.save!
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"] == "preview" && @import.valid?
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
- # flash[:notice] = t('.flash.cancel', id: @import.id)
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).perform_later(JSON.dump(attributes), index, import.id) if delay.present?
148
- Importo::ImportJob.perform_later(JSON.dump(attributes), index, import.id) unless delay.present?
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, params)
7
- import = Import.find(batch.properties[:import_id])
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
- class ImportJob < ApplicationJob
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
- self.class.execute_row(attributes, index, import_id, false)
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
- # if Importo.config.batch_adapter == Importo::SidekiqBatchAdapter
22
- # batch = Importo::SidekiqBatchAdapter.find(bid)
34
+ if Importo.config.batch_adapter == Importo::SidekiqBatchAdapter
35
+ batch = Importo::SidekiqBatchAdapter.find(bid)
23
36
 
24
- # if !import.completed? && import.can_complete? && batch.finished?
25
- # ImportJobCallback.new.on_complete("success", {import_id: import.id})
26
- # end
27
- # end
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 'preview', value: 'preview', class: 'button secondary'
7
+ = f.button 'Preview', value: 'Preview', class: 'button secondary'
8
8
  - card.with_action
9
- = f.submit nil, value: 'upload'
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
- / = f.button 'Cancel', value: 'cancel'
5
- = f.submit 'Upload', value: 'upload'
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
@@ -15,7 +15,8 @@ en:
15
15
  example: Example
16
16
  imports:
17
17
  cancel:
18
- success: "Import canceled for id %{id}, Redirecting to new"
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
- cancel: Cancel
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
- # Importo::ImportJob.send(:include, Sidekiq::Job)
79
- # Importo::ImportJob.send(:include, Importo::SidekiqBatchAdapter::ImportJobIncludes)
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)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Importo
4
- VERSION = "3.0.23"
4
+ VERSION = "3.0.24"
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.23
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-11-24 00:00:00.000000000 Z
12
+ date: 2025-12-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: caxlsx