sibu_apidae 0.3.1 → 0.3.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 +5 -5
- data/lib/sibu_apidae/version.rb +1 -1
- data/lib/sibu_apidae.rb +15 -7
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 8983707bab687f21f501cfd22611c6e4c375c47537d6428001b793e2f2e3456b
|
4
|
+
data.tar.gz: 6f60119bf825b0ce4b670e6f5dd608970d309b6f65e0388ebe7ef3dfe04b7b0b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d8cc3d9b641c7cee2f6685dc32923cf190c0c969edd0533ba60885f7e36dc3a3356328a77ac9819be4843f537601c9e3b21eb1cc52278fbd11e78ed109c108ff
|
7
|
+
data.tar.gz: 58aa1dc46d89e0391d49fa693b8b11ba8ab230f76b6d4e64e43871009c7ce4f48d18725da123a430727ee0eca09b1fa0d8d1275a019a550f1354c219e243e7bd
|
data/lib/sibu_apidae/version.rb
CHANGED
data/lib/sibu_apidae.rb
CHANGED
@@ -33,11 +33,13 @@ module SibuApidae
|
|
33
33
|
|
34
34
|
APIDAE_OBJ_SOURCE = 'Fiche Apidae'
|
35
35
|
|
36
|
-
def self.update_pages(site_id)
|
36
|
+
def self.update_pages(site_id, obj_apidae_id = nil)
|
37
37
|
conf = Rails.application.config.sibu_apidae
|
38
38
|
if is_valid?(conf)
|
39
|
-
Sibu::Page.where(site_id: site_id).
|
40
|
-
|
39
|
+
apidae_pages = Sibu::Page.where(site_id: site_id).where("metadata LIKE '%\"source\":\"#{APIDAE_OBJ_SOURCE}\"%'")
|
40
|
+
.select(:id, :site_id, :metadata).to_a
|
41
|
+
apidae_pages = apidae_pages.select {|p| p.external_id == obj_apidae_id} unless obj_apidae_id.blank?
|
42
|
+
apidae_pages.each do |p|
|
41
43
|
obj = Apidae::Obj.find_by_apidae_id(p.external_id)
|
42
44
|
if obj
|
43
45
|
p.update(name: obj.title, title: obj.title, description: obj.short_desc,
|
@@ -47,11 +49,16 @@ module SibuApidae
|
|
47
49
|
p.destroy
|
48
50
|
end
|
49
51
|
end
|
52
|
+
Rails.logger.info("Completed sibu pages update/delete for site #{site_id}")
|
50
53
|
|
51
|
-
|
54
|
+
apidae_pages = Sibu::Page.where(site_id: site_id).where("metadata LIKE '%\"source\":\"#{APIDAE_OBJ_SOURCE}\"%'")
|
55
|
+
.select(:id, :site_id, :metadata).to_a
|
56
|
+
apidae_pages = apidae_pages.select {|p| p.external_id == obj_apidae_id} unless obj_apidae_id.blank?
|
57
|
+
|
58
|
+
objs = obj_apidae_id.blank? ? Apidae::Obj.all : Apidae::Obj.where(apidae_id: obj_apidae_id)
|
59
|
+
objs.each do |obj|
|
52
60
|
if conf[:supported_types].include?(obj.apidae_type)
|
53
|
-
obj_page =
|
54
|
-
.find {|p| p.source == APIDAE_OBJ_SOURCE && p.external_id == obj.apidae_id}
|
61
|
+
obj_page = apidae_pages.find {|p| p.external_id == obj.apidae_id}
|
55
62
|
unless obj_page
|
56
63
|
p = Sibu::Page.new(name: obj.title, site_id: site_id, path: conf[:obj_path].call(obj), title: obj.title,
|
57
64
|
description: obj.short_desc, source: APIDAE_OBJ_SOURCE,
|
@@ -61,11 +68,12 @@ module SibuApidae
|
|
61
68
|
end
|
62
69
|
end
|
63
70
|
end
|
71
|
+
Rails.logger.info("Completed sibu pages creation for site #{site_id}")
|
64
72
|
else
|
65
73
|
Rails.logger.error "Please provide a valid configuration for the sibu_apidae gem " +
|
66
74
|
"(:page_external_id, :obj_path, :obj_sections and :supported_types are required)"
|
67
75
|
end
|
68
|
-
|
76
|
+
"SibuApidae pages update complete for site #{site_id}"
|
69
77
|
end
|
70
78
|
|
71
79
|
def self.is_valid?(conf)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sibu_apidae
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jean-Baptiste Vilain
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2023-03-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -119,8 +119,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
119
119
|
- !ruby/object:Gem::Version
|
120
120
|
version: '0'
|
121
121
|
requirements: []
|
122
|
-
|
123
|
-
rubygems_version: 2.6.13
|
122
|
+
rubygems_version: 3.1.6
|
124
123
|
signing_key:
|
125
124
|
specification_version: 4
|
126
125
|
summary: A set of utility classes for use with the Sibu and Apidae engines
|