imp_exp 1.1.1 → 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: 42f84a9aaed6b4a80794ed02449694a7f0c50d6dc841f27ec14c69fcd7bb652a
4
- data.tar.gz: 966b67cb74a39106e413662f39a0459f763f3633312ed0bbfbffa63927962fd8
3
+ metadata.gz: b590fb77458ecbbde482ccc594ac06b3480551b6f32ad6361c9e34b30cd4c49b
4
+ data.tar.gz: 5ac34f8c6a50ec3a2d1571ffa83ccb9a07241c1822ab4860b217d3980c941961
5
5
  SHA512:
6
- metadata.gz: b2de04fb8dc295e3b4358b552c95dbe005eecb667332ac5ce3656c496c7e9a087ce7be6c4a3f7aff92694db32b542b92e73dcae92f38ebbf93151595fba80db1
7
- data.tar.gz: 4099b4a62d555bc165852b1cf78c9ce3389804c930d03f9d91caae8c2fc8a3c793a15d79efd4fc61a666353a330ab6da4045aa2e72cd6e7f34fecced51eab6da
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.1"
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.1
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dev team Nerya