imp_exp 1.1.0 → 1.1.2

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: 4d35cc9e0a056b4cdeb9ea2b0aad6259511d2a0b3d55535f2808d782ef174412
4
- data.tar.gz: 2d2b14ed1634c50d8f7a8ce39982e29d16580c3dbcde86712c6f4e2da2e93166
3
+ metadata.gz: b590fb77458ecbbde482ccc594ac06b3480551b6f32ad6361c9e34b30cd4c49b
4
+ data.tar.gz: 5ac34f8c6a50ec3a2d1571ffa83ccb9a07241c1822ab4860b217d3980c941961
5
5
  SHA512:
6
- metadata.gz: ad4b450b14057905fe653ffb6647ca8d4cc38352ab4544a1600005ed949794692acecc1e049cdb51a097f017400e7eaa074747615039bd2d55f942926c908c66
7
- data.tar.gz: bfdcfee742ca14303e3c671579c19578090405408675da282886ec2b6dbd3256315662272d0567426969ff00d8d06c9e835aabc414d7455c47498031b38f1666
6
+ metadata.gz: 1551c0ad5706897955e9be29229686b9b1c65b0307654114c23dea08ce62771e90bbdcbcc5df867012b0ed9e8774caffded874cc5d4da6ed62ecc450e9c14162
7
+ data.tar.gz: b677f5e62d8e066bc1254efdfc00faa15f39266ddb95945d2e800f5178b912a25e87cc14ff7a80d0d4ae9a789b7ae5d4908cd23eb7ace35dede73161c011c4da
@@ -81,9 +81,15 @@ module ImpExp
81
81
  next
82
82
  end
83
83
 
84
- if record.save(context: :import)
85
- model.after_save(record)
86
- @imported[model.model_name] += 1
84
+ begin
85
+ if record.save(context: :import)
86
+ model.after_save(record)
87
+ @imported[model.model_name] += 1
88
+ next
89
+ end
90
+ rescue ActiveRecord::RecordNotUnique => e
91
+ message = I18n.t('imp_exp.importer.record_not_unique', details: unique_violation_details_suffix(e))
92
+ upsert_error_messages(model_name, line, row.to_s, message)
87
93
  next
88
94
  end
89
95
 
@@ -97,6 +103,12 @@ module ImpExp
97
103
  Rails.env.local?
98
104
  end
99
105
 
106
+ def unique_violation_details_suffix(exception)
107
+ details = exception.cause&.message || exception.message
108
+ details = details.to_s.strip
109
+ details.present? ? "(#{details})" : ""
110
+ end
111
+
100
112
  def attributes_from_row(row, model)
101
113
  row.slice(*model.attribute_to_import_names)
102
114
  end
@@ -4,6 +4,7 @@ en:
4
4
  invalid_columns: "The %{model_name} sheet does not contain the expected columns. Expected columns: %{expected_columns} Columns in the file: %{in_file_columns}."
5
5
  invalid_sheets: "The file does not contain the expected sheets. Expected sheets: %{expected_sheets} Sheets in the file: %{in_file_sheets}."
6
6
  record_not_found: "%{model_name} with %{conditions} conditions has not been found."
7
+ record_not_unique: "Unique constraint violation. Check the code field. Details: %{details}."
7
8
  wrong_format: "Format error: %{message}."
8
9
  model_errors: "%{model_name} sheet - Row %{line}: %{messages}"
9
10
  data_validation_error: "%{model_name} sheet - Row %{line} - Column \"%{column}\": value \"%{value}\" incorrect, expected value: %{expected}"
@@ -4,7 +4,8 @@ fr:
4
4
  invalid_columns: "La feuille %{model_name} ne contient pas les colonnes attendues. Colonnes attendues : %{expected_columns}. Colonnes dans le fichier : %{in_file_columns}."
5
5
  invalid_sheets: "Le fichier ne contient pas les feuilles attendues. Feuilles attendues : %{expected_sheets}. Feuilles dans le fichier : %{in_file_sheets}."
6
6
  record_not_found: "%{model_name} avec les conditions %{conditions} n'a pas été trouvé."
7
+ record_not_unique: "Violation de contrainte d'unicité. Vérifiez les champs code. Détails : %{details}."
7
8
  wrong_format: "Erreur de format : %{message}."
8
9
  model_errors: "Feuille %{model_name} - Ligne %{line} : %{messages}"
9
10
  data_validation_error: "Feuille %{model_name} - Ligne %{line} - Colonne \"%{column}\" : valeur \"%{value}\" incorrecte, valeur attendue : %{expected}"
10
- file_not_found: "Fichier %{file_path} non trouvé."
11
+ file_not_found: "Fichier %{file_path} non trouvé."
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ImpExp
4
- VERSION = "1.1.0"
4
+ VERSION = "1.1.2"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: imp_exp
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dev team Nerya
@@ -46,7 +46,7 @@ dependencies:
46
46
  version: 7.2.0
47
47
  - - "<"
48
48
  - !ruby/object:Gem::Version
49
- version: 8.1.0
49
+ version: 8.2.0
50
50
  type: :runtime
51
51
  prerelease: false
52
52
  version_requirements: !ruby/object:Gem::Requirement
@@ -56,7 +56,7 @@ dependencies:
56
56
  version: 7.2.0
57
57
  - - "<"
58
58
  - !ruby/object:Gem::Version
59
- version: 8.1.0
59
+ version: 8.2.0
60
60
  - !ruby/object:Gem::Dependency
61
61
  name: rubyzip
62
62
  requirement: !ruby/object:Gem::Requirement
@@ -139,7 +139,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
139
139
  - !ruby/object:Gem::Version
140
140
  version: '0'
141
141
  requirements: []
142
- rubygems_version: 3.6.9
142
+ rubygems_version: 4.0.3
143
143
  specification_version: 4
144
144
  summary: Import data from xlsx into a rails app and export data to xlsx from a rails
145
145
  app