apidae 1.3.11 → 1.3.14
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8b0a75e107222c0e4c95387eb3f11641bfa62796c499c46915366a7035b8c685
|
4
|
+
data.tar.gz: 567423739b0f9f87341111fe33b6e2260465d47583ab282fef0234b1f5e79cf7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 49b000ca4218681cabfa00dea2ec31c28fe4d0cd9fb7147a1ca23f411e1c659caf711a229c736c6c4971d0827411d9682b90aea751f4ef297f5f1c241fee9983
|
7
|
+
data.tar.gz: 5655202cdbeb55bc7103563933631b082d0827de6b9fab2335630312a3fca1304cfd96ac33c931867338bf4264dc2e9cb6f9dab5fe438d87b20d77936c752759
|
@@ -37,7 +37,10 @@ module Apidae
|
|
37
37
|
def run
|
38
38
|
success = true
|
39
39
|
Export.pending.each do |e|
|
40
|
+
logger.info "Running import for Apidae export #{e.id} - Project #{e.project.id}"
|
41
|
+
e.update(status: Export::IN_PROGRESS)
|
40
42
|
success &&= e.import_data
|
43
|
+
logger.info "Apidae export #{e.id} import run complete - Project #{e.project.id}"
|
41
44
|
end
|
42
45
|
success ? head(:ok) : head(:internal_server_error)
|
43
46
|
end
|
data/app/models/apidae/export.rb
CHANGED
@@ -5,6 +5,7 @@ module Apidae
|
|
5
5
|
class Export < ActiveRecord::Base
|
6
6
|
|
7
7
|
PENDING = 'pending'
|
8
|
+
IN_PROGRESS = 'in_progress'
|
8
9
|
COMPLETE = 'complete'
|
9
10
|
CANCELLED = 'cancelled'
|
10
11
|
|
@@ -24,11 +25,16 @@ module Apidae
|
|
24
25
|
where(remote_status: 'SUCCESS', status: PENDING).order(:id)
|
25
26
|
end
|
26
27
|
|
28
|
+
def self.in_progress
|
29
|
+
where(remote_status: 'SUCCESS', status: IN_PROGRESS)
|
30
|
+
end
|
31
|
+
|
27
32
|
def import_data
|
28
33
|
success = true
|
29
34
|
begin
|
30
35
|
open(file_url) do |f|
|
31
36
|
begin
|
37
|
+
logger.info "Starting file import for export #{id} - project #{project_id}"
|
32
38
|
FileImport.import(f, project_id)
|
33
39
|
unless confirm_url.blank?
|
34
40
|
uri = URI(confirm_url)
|
@@ -36,11 +42,13 @@ module Apidae
|
|
36
42
|
Net::HTTP.start(uri.hostname, uri.port) do |http|
|
37
43
|
http.request(req)
|
38
44
|
end
|
45
|
+
logger.info "Posted file import callback for export #{id} - project #{project_id}"
|
39
46
|
end
|
40
47
|
update(status: Export::COMPLETE)
|
41
48
|
if Rails.application.config.respond_to?(:apidae_import_callback)
|
42
49
|
Rails.application.config.apidae_import_callback.call(self)
|
43
50
|
end
|
51
|
+
logger.info "Completed file import for export #{id} - project #{project_id}"
|
44
52
|
rescue Exception => ex
|
45
53
|
logger.error("Failed to import export file : #{file_url}")
|
46
54
|
logger.error("Error is : #{ex} \n#{ex.backtrace.join("\n") unless ex.backtrace.blank?}")
|
@@ -12,15 +12,17 @@ module Apidae
|
|
12
12
|
def self.import(refs_json)
|
13
13
|
locales = Rails.application.config.respond_to?(:apidae_locales) ? Rails.application.config.apidae_locales : [DEFAULT_LOCALE]
|
14
14
|
locales_map = Hash[locales.map {|loc| ["libelle#{loc.camelize.gsub('-', '')}".to_sym, loc]}]
|
15
|
-
|
16
|
-
|
17
|
-
refs_hashes.
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
15
|
+
if count == 0 || Time.current > (maximum(:updated_at) + 1.day)
|
16
|
+
refs_hashes = JSON.parse(refs_json, symbolize_names: true)
|
17
|
+
if refs_hashes.length != where("apidae_type != ?", INTERNAL).count
|
18
|
+
refs_hashes.each do |ref_data|
|
19
|
+
ref = Reference.find_or_initialize_by(apidae_id: ref_data[:id], apidae_type: ref_data[:elementReferenceType])
|
20
|
+
ref.label_data = ref_data.slice(*locales_map.keys).transform_keys {|k| locales_map[k]}
|
21
|
+
ref.parent = ref_data[:parent][:id] if ref_data[:parent]
|
22
|
+
ref.category = ref_data[:familleCritere] ? ref_data[:familleCritere][:id] : (ref_data[:typeLabel] ? ref_data[:typeLabel][:id] : nil)
|
23
|
+
ref.is_active = ref_data[:actif]
|
24
|
+
ref.save!
|
25
|
+
end
|
24
26
|
end
|
25
27
|
end
|
26
28
|
end
|
data/lib/apidae/version.rb
CHANGED
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.3.
|
4
|
+
version: 1.3.14
|
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: 2022-
|
11
|
+
date: 2022-07-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|