eco-helpers 2.1.1 → 2.1.3
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 +4 -4
- data/CHANGELOG.md +31 -2
- data/eco-helpers.gemspec +2 -2
- data/lib/eco/api/session/config/api.rb +1 -1
- data/lib/eco/api/session/config.rb +18 -0
- data/lib/eco/api/session.rb +5 -0
- data/lib/eco/api/usecases/ooze_samples/ooze_base_case.rb +33 -22
- data/lib/eco/api/usecases/ooze_samples/register_update_case.rb +9 -1
- data/lib/eco/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bd18bdf6133a2fa0ccc023a3bdf11140b9af98364bfa6327f171e93373ee51f0
|
4
|
+
data.tar.gz: 4918192e55fe12081ba8db062b2bdcaf8afd1058732a93d23cd1180015af623a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8bdd14bfa761ce494c920bd4242d49b9bfb37eb91b2021a7f1d4799b10e09a3d0af66491aca287c8d15874d436a77e9e94e4b1237e3925795b48b2df7876ec92
|
7
|
+
data.tar.gz: 06cc22d088ef35c755ed554578c58357782443a48ba0542fe21c13dc332b87123fb244bd8f98f805e9801b011cec309e33166c57876c7456cb101bf1bbd37867
|
data/CHANGELOG.md
CHANGED
@@ -1,13 +1,42 @@
|
|
1
1
|
# Change Log
|
2
2
|
All notable changes to this project will be documented in this file.
|
3
3
|
|
4
|
-
## [2.1.
|
4
|
+
## [2.1.4] - 2022-10-xx
|
5
5
|
|
6
6
|
### Added
|
7
7
|
### Changed
|
8
8
|
### Fixed
|
9
9
|
|
10
|
-
## [2.1.
|
10
|
+
## [2.1.3] - 2022-10-11
|
11
|
+
|
12
|
+
### Added
|
13
|
+
- `Eco::API::UseCases::OozeSamples::OozeBaseCase`
|
14
|
+
- `with_fields`, `with_sections` and `add_field` accept an `entry` parameter
|
15
|
+
- also did some internal refactor
|
16
|
+
|
17
|
+
### Changed
|
18
|
+
- Upgraded `ecoportal-api-v2` **gem**
|
19
|
+
|
20
|
+
### Fixed
|
21
|
+
- `Eco::API::UseCases::OozeSamples::RegisterUpdateCase`
|
22
|
+
- account for stages with updates within same entry
|
23
|
+
|
24
|
+
## [2.1.2] - 2022-09-29
|
25
|
+
|
26
|
+
### Added
|
27
|
+
- `Ecoportal::API::Session::Config#live_tree` to retrieve the tagtree of the back-end
|
28
|
+
- Requires `graphql` connection parameters
|
29
|
+
- `Ecoportal::API::Session#live_tree` see above
|
30
|
+
|
31
|
+
### Changed
|
32
|
+
- `Ecoportal::API::Session::Config#tagtree` to use `#live_tree` if there isn't a `tagtree.json` file
|
33
|
+
- upgraded **dependency** to `ecoportal-api-graphql` **gem**
|
34
|
+
- upgraded **dependency** to `ecoportal-api-v2` **gem**
|
35
|
+
|
36
|
+
### Fixed
|
37
|
+
- `Ecoportal::API::Session::Config::API#version_available?` **typo**
|
38
|
+
|
39
|
+
## [2.1.1] - 2022-09-26
|
11
40
|
|
12
41
|
### Added
|
13
42
|
- `Eco::API::Session::Config::Api#version_available?` to know if a version is available for use
|
data/eco-helpers.gemspec
CHANGED
@@ -31,8 +31,8 @@ Gem::Specification.new do |spec|
|
|
31
31
|
spec.add_development_dependency "redcarpet", ">= 3.5.1", "< 3.6"
|
32
32
|
|
33
33
|
spec.add_dependency 'ecoportal-api', '>= 0.8.5', '< 0.9'
|
34
|
-
spec.add_dependency 'ecoportal-api-v2', '>= 0.9.
|
35
|
-
spec.add_dependency 'ecoportal-api-graphql', '>= 0.1.
|
34
|
+
spec.add_dependency 'ecoportal-api-v2', '>= 0.9.3', '< 0.10'
|
35
|
+
spec.add_dependency 'ecoportal-api-graphql', '>= 0.1.10', '< 0.2'
|
36
36
|
spec.add_dependency 'aws-sdk-s3', '>= 1.83.0', '< 2'
|
37
37
|
spec.add_dependency 'aws-sdk-ses', '>= 1.36.0', '< 2'
|
38
38
|
spec.add_dependency 'dotenv', '>= 2.7.6', '< 2.8'
|
@@ -228,6 +228,7 @@ module Eco
|
|
228
228
|
org["tagtree"] = file
|
229
229
|
end
|
230
230
|
|
231
|
+
# It uses the `tagtree.json` file and in its absence, if `graphql` enabled, the `life_tagtree`
|
231
232
|
# @return [Eco::API::Organization::TagTree]
|
232
233
|
def tagtree(enviro: nil)
|
233
234
|
return @tagtree if instance_variable_defined?(:@tagtree) && @tagtree.enviro == enviro
|
@@ -235,6 +236,23 @@ module Eco
|
|
235
236
|
tree = []
|
236
237
|
tree = file_manager.load_json(tree_file) unless !tree_file
|
237
238
|
@tagtree = Eco::API::Organization::TagTree.new(tree, enviro: enviro)
|
239
|
+
else
|
240
|
+
@tagtree = live_tree(enviro: enviro)
|
241
|
+
end
|
242
|
+
end
|
243
|
+
|
244
|
+
# It obtains the first of the live tagtree in the org
|
245
|
+
# @note it requires graphql connection configuration parameters
|
246
|
+
# @return [Eco::API::Organization::TagTree]
|
247
|
+
def live_tree(enviro: nil)
|
248
|
+
return @live_tree if instance_variable_defined?(:@live_tree) && @live_tree.enviro == enviro
|
249
|
+
if apis.active_api.version_available?(:graphql)
|
250
|
+
graphql = apis.api(version: :graphql)
|
251
|
+
if tree = graphql.currentOrganization.tagTrees.to_a.first.treeify
|
252
|
+
@live_tree = Eco::API::Organization::TagTree.new(tree, enviro: enviro)
|
253
|
+
else
|
254
|
+
@live_tree = nil
|
255
|
+
end
|
238
256
|
end
|
239
257
|
end
|
240
258
|
|
data/lib/eco/api/session.rb
CHANGED
@@ -46,30 +46,30 @@ class Eco::API::UseCases::OozeSamples::OozeBaseCase < Eco::API::Common::Loaders:
|
|
46
46
|
ooze(ooze_id, stage_id: stage_id)
|
47
47
|
end
|
48
48
|
|
49
|
-
def add_field_by_doc(doc, section, after: nil, before: nil, side: :left)
|
49
|
+
def add_field_by_doc(doc, section, entry: target, after: nil, before: nil, side: :left)
|
50
50
|
unless section.is_a?(Ecoportal::API::V2::Page::Section)
|
51
51
|
raise "You need to specify a section for a new field. Given: #{section.class}"
|
52
52
|
end
|
53
|
-
|
53
|
+
entry.components.add(doc: doc) do |field|
|
54
54
|
section.add_component(field, after: after, before: before, side: side)
|
55
55
|
end.tap do |field|
|
56
56
|
yield(field) if block_given?
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
60
|
-
def add_field(name, type, section, after: nil, before: nil, side: :left)
|
60
|
+
def add_field(name, type, section, entry: target, after: nil, before: nil, side: :left)
|
61
61
|
unless section.is_a?(Ecoportal::API::V2::Page::Section)
|
62
62
|
raise "You need to specify a section for a new field. Given: #{section.class}"
|
63
63
|
end
|
64
|
-
|
64
|
+
entry.components.add(label: name, type: type) do |field|
|
65
65
|
section.add_component(field, after: after, before: before, side: side)
|
66
66
|
end.tap do |field|
|
67
67
|
yield(field) if block_given?
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
71
|
-
def with_fields(type: nil, label: nil)
|
72
|
-
flds =
|
71
|
+
def with_fields(entry = target, type: nil, label: nil)
|
72
|
+
flds = entry.components
|
73
73
|
flds = flds.get_by_type(type) if type
|
74
74
|
flds = flds.select do |fld|
|
75
75
|
value = (label == :unnamed) ? nil : label
|
@@ -79,8 +79,8 @@ class Eco::API::UseCases::OozeSamples::OozeBaseCase < Eco::API::Common::Loaders:
|
|
79
79
|
end
|
80
80
|
end
|
81
81
|
|
82
|
-
def with_sections(type: nil, heading: nil)
|
83
|
-
secs =
|
82
|
+
def with_sections(entry = target, type: nil, heading: nil)
|
83
|
+
secs = entry.sections
|
84
84
|
secs = secs.get_by_type(type) if type
|
85
85
|
secs = secs.select do |sec|
|
86
86
|
value = (heading == :unnamed) ? nil : heading
|
@@ -141,7 +141,10 @@ class Eco::API::UseCases::OozeSamples::OozeBaseCase < Eco::API::Common::Loaders:
|
|
141
141
|
# It fill update the ooze only if it's dirty (it carries changes)
|
142
142
|
# @return [Boolean, Response] `false` if there was not request against the server, `Response` otherwise
|
143
143
|
def update_ooze(ooze = target)
|
144
|
-
if
|
144
|
+
if options[:simulate]
|
145
|
+
dry_run_feedback(ooze)
|
146
|
+
false
|
147
|
+
else
|
145
148
|
return false unless dirty?(ooze)
|
146
149
|
|
147
150
|
ooze.validate.tap do |validation|
|
@@ -156,19 +159,6 @@ class Eco::API::UseCases::OozeSamples::OozeBaseCase < Eco::API::Common::Loaders:
|
|
156
159
|
logger.error("Could not update #{object_reference(ooze)} (created_at: #{ooze.created_at}: #{response.body}")
|
157
160
|
end
|
158
161
|
end
|
159
|
-
else
|
160
|
-
ooze.validate.tap do |validation|
|
161
|
-
logger.error(validation) if validation.is_a?(String)
|
162
|
-
end
|
163
|
-
unless options.dig(:feedback, :only_stats)
|
164
|
-
if patch = (patch_doc(ooze) || {})["page"]
|
165
|
-
pp patch
|
166
|
-
end
|
167
|
-
end
|
168
|
-
|
169
|
-
backup_patch!(ooze)
|
170
|
-
exit(0) if dirty?(ooze) && dry_count > DRY_COUNT
|
171
|
-
false
|
172
162
|
end
|
173
163
|
end
|
174
164
|
|
@@ -204,6 +194,14 @@ class Eco::API::UseCases::OozeSamples::OozeBaseCase < Eco::API::Common::Loaders:
|
|
204
194
|
puts "Saved patch at: #{File.expand_path(SAVE_PATCH)}"
|
205
195
|
end
|
206
196
|
|
197
|
+
def display_patch(entry = target)
|
198
|
+
unless options.dig(:feedback, :only_stats)
|
199
|
+
if patch = (patch_doc(entry) || {})["page"]
|
200
|
+
pp patch
|
201
|
+
end
|
202
|
+
end
|
203
|
+
end
|
204
|
+
|
207
205
|
def patch_doc(ooze = target)
|
208
206
|
apiv2.pages.get_body(ooze)
|
209
207
|
end
|
@@ -213,6 +211,19 @@ class Eco::API::UseCases::OozeSamples::OozeBaseCase < Eco::API::Common::Loaders:
|
|
213
211
|
@dry_count += 1
|
214
212
|
end
|
215
213
|
|
214
|
+
def dry_run_feedback(entry = target)
|
215
|
+
entry.validate.tap do |validation|
|
216
|
+
logger.error(validation) if validation.is_a?(String)
|
217
|
+
end
|
218
|
+
display_patch(entry)
|
219
|
+
backup_patch!(entry)
|
220
|
+
if dirty?(entry) && dry_count > self.class::DRY_COUNT
|
221
|
+
logger.info("Reached #{self.class::DRY_COUNT} dry-run samples.")
|
222
|
+
exit(0)
|
223
|
+
end
|
224
|
+
false
|
225
|
+
end
|
226
|
+
|
216
227
|
def apiv2
|
217
228
|
@apiv2 ||= session.api(version: :oozes)
|
218
229
|
end
|
@@ -52,7 +52,15 @@ class Eco::API::UseCases::OozeSamples::RegisterUpdateCase < Eco::API::UseCases::
|
|
52
52
|
|
53
53
|
def before_loading_new_target(ooze_id)
|
54
54
|
if pending = queue_shift(ooze_id)
|
55
|
-
update_ooze(pending)
|
55
|
+
update_ooze(pending).tap do |result|
|
56
|
+
if result.is_a?(Ecoportal::API::Common::Response)
|
57
|
+
if result.success?
|
58
|
+
@updated_oozes += 1
|
59
|
+
else
|
60
|
+
@failed_update_oozes +=1
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
56
64
|
end
|
57
65
|
end
|
58
66
|
|
data/lib/eco/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eco-helpers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Oscar Segura
|
@@ -136,7 +136,7 @@ dependencies:
|
|
136
136
|
requirements:
|
137
137
|
- - ">="
|
138
138
|
- !ruby/object:Gem::Version
|
139
|
-
version: 0.9.
|
139
|
+
version: 0.9.3
|
140
140
|
- - "<"
|
141
141
|
- !ruby/object:Gem::Version
|
142
142
|
version: '0.10'
|
@@ -146,7 +146,7 @@ dependencies:
|
|
146
146
|
requirements:
|
147
147
|
- - ">="
|
148
148
|
- !ruby/object:Gem::Version
|
149
|
-
version: 0.9.
|
149
|
+
version: 0.9.3
|
150
150
|
- - "<"
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: '0.10'
|
@@ -156,7 +156,7 @@ dependencies:
|
|
156
156
|
requirements:
|
157
157
|
- - ">="
|
158
158
|
- !ruby/object:Gem::Version
|
159
|
-
version: 0.1.
|
159
|
+
version: 0.1.10
|
160
160
|
- - "<"
|
161
161
|
- !ruby/object:Gem::Version
|
162
162
|
version: '0.2'
|
@@ -166,7 +166,7 @@ dependencies:
|
|
166
166
|
requirements:
|
167
167
|
- - ">="
|
168
168
|
- !ruby/object:Gem::Version
|
169
|
-
version: 0.1.
|
169
|
+
version: 0.1.10
|
170
170
|
- - "<"
|
171
171
|
- !ruby/object:Gem::Version
|
172
172
|
version: '0.2'
|