apidae 1.2.19 → 1.2.23

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: f0533c1fd04de205f113339f04a402ce3ade60a4c0a47a75b947337e041ba936
4
- data.tar.gz: fb9eee8ff01c807e496b824e98df76a44f71c30864e882ac1a533e1e399a44b7
3
+ metadata.gz: 2407ded3bf635d320fc63285f4856a6665cf01f4bd59ffcc61dd5b4fbd5c0195
4
+ data.tar.gz: a6015865bc0699672c36abec0628cfc22031ab4bec70ee49a26a33134c459f9b
5
5
  SHA512:
6
- metadata.gz: 1df1ce2301d3ba225cf85afa85f68bac3fb1e3a603b8222840972c6df65e40ff0cac84871699fc41371c47489ea2dce77f4b487682787777e2428fa637b8dec6
7
- data.tar.gz: 4dda8701538ab5a7f2e3956f6c9d69827ae2648477346ed914680fa2e9a80f2207ba441188dd32df006bee9ad91c6dbf7da77fc401395072d4a598451ecf1d44
6
+ metadata.gz: '08f5b492b0e87e04e51de3fd8f91274c89f5420648effb6a48113aa0b567ba4bf6c6041e0c7c56f2c66b6478f9cae6ce32f4af3d83f9bdd9b35a36db2d81fbef'
7
+ data.tar.gz: d44a1b68ac1bb5155e280f743aa985ea3487b92939f4857ce2eacb73afda126eded590ee562c768a6f64eef3ad88cc6441d2e2702d4780abfdfe4c3642bc3a1f
@@ -113,7 +113,7 @@ module Apidae
113
113
  short_desc: node_value(data_hash, :descriptifCourt, *locales),
114
114
  long_desc: node_value(data_hash, :descriptifDetaille, *locales),
115
115
  theme_desc: data_hash[:descriptifsThematises].blank? ? {} : Hash[data_hash[:descriptifsThematises].map {|th| [node_id(th, :theme), node_value(th, :description, *locales)]}],
116
- private_desc: private_data.blank? ? {} : Hash[private_data.map {|d| [d[:nomTechnique], node_value(d, :descriptif, *locales)]}]
116
+ private_desc: private_data.blank? ? {} : Hash[private_data.map {|d| [d[:nomTechnique], {LOCALE_FR => d[:libelleFr]} || node_value(d, :descriptif, *locales)]}]
117
117
  }
118
118
  end
119
119
  end
@@ -44,6 +44,7 @@ module Apidae
44
44
  end
45
45
  end
46
46
  end
47
+ project.cleanup_selections
47
48
  create(result.except(:selections)
48
49
  .merge({remote_file: (zip_file.is_a?(File) ? zip_file.path : zip_file), status: STATUS_COMPLETE, apidae_id: project_id}))
49
50
  logger.info "Import results : #{result}"
@@ -169,7 +170,9 @@ module Apidae
169
170
  def self.add_or_update_selections(project, selections_json, result)
170
171
  selections_hashes = JSON.parse(selections_json, symbolize_names: true)
171
172
  deleted_ids = Selection.where(apidae_project_id: project.id).collect {|sel| sel.apidae_id}.uniq - selections_hashes.collect {|sel| sel[:id]}
172
- Selection.where(apidae_id: deleted_ids).delete_all
173
+ apidae_selection_ids = Selection.where(apidae_id: deleted_ids).map {|s| s.id}
174
+ SelectionObject.where(apidae_selection_id: apidae_selection_ids).delete_all
175
+ Selection.where(id: apidae_selection_ids).delete_all
173
176
  selections_hashes.each do |selection_data|
174
177
  logger.info "Updating selection #{selection_data[:id]}"
175
178
  Selection.add_or_update(selection_data, project.id)
@@ -20,5 +20,11 @@ module Apidae
20
20
  def versions=(values)
21
21
  self.versions_data = values.blank? ? nil : values.join('|')
22
22
  end
23
+
24
+ def cleanup_selections
25
+ apidae_selections.reload.each do |s|
26
+ s.cleanup
27
+ end
28
+ end
23
29
  end
24
30
  end
@@ -42,6 +42,20 @@ module Apidae
42
42
  SelectionObject.where(apidae_selection_id: apidae_sel.id, apidae_object_id: removed_ids).delete_all
43
43
  end
44
44
 
45
+ def cleanup
46
+ obsolete_count = apidae_selection_objects
47
+ .joins("LEFT JOIN apidae_objs ON apidae_objs.id = apidae_selection_objects.apidae_object_id")
48
+ .where("apidae_objs.id IS NULL")
49
+ .delete_all
50
+ logger.info "Cleaned up #{obsolete_count} obsolete selection-objects associations for selection #{apidae_id}"
51
+
52
+ dups = apidae_selection_objects.reload.group(:apidae_object_id)
53
+ .select("COUNT(id), apidae_object_id, ARRAY_AGG(id) AS so_ids")
54
+ .having("COUNT(id) > ?", 1).map {|so| so.so_ids}
55
+ dups_count = apidae_selection_objects.where(id: dups.map {|d| d.sort[1..-1]}.flatten).delete_all
56
+ logger.info "Cleaned up #{dups_count} duplicate selection-objects associations for selection #{apidae_id}"
57
+ end
58
+
45
59
  def results(where_clause, offset, size)
46
60
  objects.includes(:town).limit(size).offset(offset).where(where_clause)
47
61
  end
@@ -1,3 +1,3 @@
1
1
  module Apidae
2
- VERSION = "1.2.19"
2
+ VERSION = "1.2.23"
3
3
  end
@@ -373,3 +373,27 @@ Check the "Autoloading and Reloading Constants" guide to learn more about how
373
373
  Rails autoloads and reloads.
374
374
  (called from <top (required)> at /Users/jbvilain/workspace/code/apidae-engine-rails/test/dummy/config/environment.rb:5)
375
375
   (170.6ms) SELECT COUNT(*) FROM "apidae_objs" WHERE "apidae_objs"."root_obj_id" IS NULL
376
+ DEPRECATION WARNING: Initialization autoloaded the constants Apidae::ApidaeHelper, Apidae::ApplicationHelper, Apidae::ApiHelper, Apidae::DashboardHelper, Apidae::ExtendableHelper, Apidae::ImportHelper, Apidae::ObjectsHelper, Apidae::ReferencesHelper, Apidae::SelectionsHelper, and Apidae::ApplicationController.
377
+
378
+ Being able to do this is deprecated. Autoloading during initialization is going
379
+ to be an error condition in future versions of Rails.
380
+
381
+ Reloading does not reboot the application, and therefore code executed during
382
+ initialization does not run again. So, if you reload Apidae::ApidaeHelper, for example,
383
+ the expected changes won't be reflected in that stale Module object.
384
+
385
+ `config.autoloader` is set to `classic`. These autoloaded constants would have been unloaded if `config.autoloader` had been set to `:zeitwerk`.
386
+
387
+ In order to autoload safely at boot time, please wrap your code in a reloader
388
+ callback this way:
389
+
390
+ Rails.application.reloader.to_prepare do
391
+ # Autoload classes and modules needed at boot time here.
392
+ end
393
+
394
+ That block runs when the application boots, and every time there is a reload.
395
+ For historical reasons, it may run twice, so it has to be idempotent.
396
+
397
+ Check the "Autoloading and Reloading Constants" guide to learn more about how
398
+ Rails autoloads and reloads.
399
+ (called from <top (required)> at /Users/jbvilain/workspace/code/apidae-engine-rails/test/dummy/config/environment.rb:5)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: apidae
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.19
4
+ version: 1.2.23
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jean-Baptiste Vilain
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-07-27 00:00:00.000000000 Z
11
+ date: 2021-09-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails