eco-helpers 2.1.7 → 2.1.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +23 -1
- data/eco-helpers.gemspec +2 -2
- data/lib/eco/api/session/batch/job.rb +31 -5
- data/lib/eco/api/session/batch/jobs.rb +4 -4
- data/lib/eco/api/session.rb +2 -2
- data/lib/eco/api/usecases/ooze_samples/ooze_base_case.rb +8 -2
- data/lib/eco/api/usecases/ooze_samples/register_migration_case.rb +1 -0
- 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: dac932bad9c679aa2f0c5aaa3a5c33ed16f04bde3ca37c55e6b19ae2cae6a418
|
4
|
+
data.tar.gz: 7d533e95f2738ba4633ac4e62ea06ff414de63b059fbc5f532b2fde4d5940233
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3bfb8e874d539c0a8d24ba1a4858130fb48c2a6e905f425bf7ca530d29c05bb01fd371a8d0fa58a9c736bd82f18409867461c6e3f3e2405a5135a700ad4f7784
|
7
|
+
data.tar.gz: a707033b2e34ca9fbc5c98514319a5d2d034aa8f37d6fd7b81ffa2d0eaddd516c9aac4471393284334225c03b7c75cdcc0cc2ac8938530cb8d53e5de23f52d68
|
data/CHANGELOG.md
CHANGED
@@ -1,12 +1,34 @@
|
|
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.10] - 2022-11-xx
|
5
5
|
|
6
6
|
### Added
|
7
7
|
### Changed
|
8
8
|
### Fixed
|
9
9
|
|
10
|
+
## [2.1.9] - 2022-11-29
|
11
|
+
|
12
|
+
### Changed
|
13
|
+
- upgrade `ecoportal-api-v2` **gem** dependency
|
14
|
+
- upgrade `ecoportal-api-graphql` **gem** dependency
|
15
|
+
|
16
|
+
### Fixed
|
17
|
+
- `Eco::API::Session::Batch::Job`
|
18
|
+
- Ability to skip prefilter of entries with no `id` on `:update`
|
19
|
+
- Enhanced error tracking (bug resilience)
|
20
|
+
|
21
|
+
## [2.1.8] - 2022-11-18
|
22
|
+
|
23
|
+
### Added
|
24
|
+
- `Eco::API::UseCases::OozeSamples::RegisterMigrationCase`
|
25
|
+
- When in `dry-run` mode, it adds one line before creation feedback, so it is clear the feedback is about creation (i.e. none of the source entries got mistakenly updated)
|
26
|
+
- **enhanced** `Eco::API::UseCases::OozeSamples::OozeBaseCase#with_fields`
|
27
|
+
- It allows to optionally pass as first parameter a section or a stage (default: ooze)
|
28
|
+
|
29
|
+
### Changed
|
30
|
+
- upgraded gem dependency `ecoportal-api-v2`
|
31
|
+
|
10
32
|
## [2.1.7] - 2022-11-17
|
11
33
|
|
12
34
|
### Added
|
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.7', '< 0.10'
|
35
|
+
spec.add_dependency 'ecoportal-api-graphql', '>= 0.1.11', '< 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'
|
@@ -34,7 +34,10 @@ module Eco
|
|
34
34
|
# @param type [Symbol] a valid batch operation.
|
35
35
|
# @param usecase [Eco::API::UseCases::UseCase, nil] when provided: `usecase` that generated this `batch job`.
|
36
36
|
# This is necessary to know the `options` used to run the usecase, which could modify the `Batch::Job` behviour.
|
37
|
-
|
37
|
+
# @param accept_update_with_no_id [Boolean] temporary contingency
|
38
|
+
# This parameter has been added due to a bug on server side.
|
39
|
+
# An external_id is still required.
|
40
|
+
def initialize(e, name:, type:, sets:, usecase: nil, accept_update_with_no_id: false)
|
38
41
|
raise "A name is required to refer a job. Given: #{name}" if !name
|
39
42
|
raise "Type should be one of #{self.class.types}. Given: #{type}" unless self.class.valid_type?(type)
|
40
43
|
raise "Sets should be some of #{self.class.sets}. Given: #{sets}" unless self.class.valid_sets?(sets)
|
@@ -46,6 +49,7 @@ module Eco
|
|
46
49
|
@sets = [sets].flatten.compact
|
47
50
|
@usecase = usecase
|
48
51
|
@feedback = Eco::API::Session::Batch::Feedback.new(job: self)
|
52
|
+
@accept_update_with_no_id = accept_update_with_no_id
|
49
53
|
reset
|
50
54
|
end
|
51
55
|
|
@@ -244,12 +248,18 @@ module Eco
|
|
244
248
|
# - The contingency above wouldn't be necessary if the server worked perfectly.
|
245
249
|
def processed_queue
|
246
250
|
pre_filtered = @queue.select do |entry|
|
251
|
+
by_pass_filter = false
|
247
252
|
if unexisting = entry.new? && !entry.id && type != :create
|
248
253
|
ref = Eco::API::Session::Batch::Feedback.person_ref(entry)
|
249
|
-
msg = "Job ('#{name}':#{type}):
|
254
|
+
msg = "Job ('#{name}':#{type}): "
|
255
|
+
if (by_pass_filter = entry.external_id && @accept_update_with_no_id)
|
256
|
+
msg << "entry errored on creation (failed creation) but will try with person code: #{ref}"
|
257
|
+
else
|
258
|
+
msg << "excluded unexisting entry (failed creation): #{ref}"
|
259
|
+
end
|
250
260
|
session.logger.warn(msg)
|
251
261
|
end
|
252
|
-
!unexisting
|
262
|
+
!unexisting || by_pass_filter
|
253
263
|
end
|
254
264
|
pre_filtered.each {|e| @callbacks[e].call(e) if @callbacks.key?(e) }
|
255
265
|
apply_policies(api_included(pre_filtered)).select do |e|
|
@@ -321,9 +331,25 @@ module Eco
|
|
321
331
|
status.queue.map do |entry|
|
322
332
|
if status.success?(entry)
|
323
333
|
if type == :create && entry.respond_to?(:id=)
|
324
|
-
entry.id = status[entry].body["id"]
|
334
|
+
entry.id = status[entry].body["id"].tap do |id|
|
335
|
+
if id.to_s.strip.empty?
|
336
|
+
ref = Eco::API::Session::Batch::Feedback.person_ref(entry)
|
337
|
+
msg = "Entry has been created but API did not return its 'id': #{ref}"
|
338
|
+
if response = status[entry]
|
339
|
+
msg << " (Response - status: #{response.status.code}; body: #{response.body.pretty_inspect})"
|
340
|
+
end
|
341
|
+
logger.error(msg)
|
342
|
+
end
|
343
|
+
end
|
344
|
+
end
|
345
|
+
if entry.respond_to?(:consolidate!)
|
346
|
+
entry.consolidate!
|
347
|
+
if entry.respond_to?(:dirty?) && entry.dirty? && entry.respond_to?(:as_update)
|
348
|
+
msg = "After consolidate there's still a dirty model:\n"
|
349
|
+
msg << entry.as_update.pretty_inspect
|
350
|
+
logger.debug(msg)
|
351
|
+
end
|
325
352
|
end
|
326
|
-
entry.consolidate! if entry.respond_to?(:consolidate!)
|
327
353
|
#else # do not entry.reset! (keep track on changes still)
|
328
354
|
end
|
329
355
|
end
|
@@ -49,9 +49,9 @@ module Eco
|
|
49
49
|
# - the block should only be passed when creating the job
|
50
50
|
# @param [see @Eco::API::Session::Batch::Jobs#new]
|
51
51
|
# @return [Eco::API::Session::Batch::Job]
|
52
|
-
def job(name, type: nil, sets: nil, usecase: nil, &block)
|
52
|
+
def job(name, type: nil, sets: nil, usecase: nil, accept_update_with_no_id: false, &block)
|
53
53
|
fatal "Can't give a job post-launch callback &block to an already existing job" if exists?(name)
|
54
|
-
new(name, type: type, sets: sets, usecase: usecase, &block) unless exists?(name)
|
54
|
+
new(name, type: type, sets: sets, usecase: usecase, accept_update_with_no_id: accept_update_with_no_id, &block) unless exists?(name)
|
55
55
|
self[name]
|
56
56
|
end
|
57
57
|
|
@@ -61,10 +61,10 @@ module Eco
|
|
61
61
|
# @yieldparam job [Eco::API::Session::Batch::Job] the job we have launched against the server.
|
62
62
|
# @yieldparam status [Eco::API::Session::Batch::Status] the status of the batch job launch.
|
63
63
|
# @return [Eco::API::Session::Batch::Job]
|
64
|
-
def new(name, type:, sets:, usecase: nil, &block)
|
64
|
+
def new(name, type:, sets:, usecase: nil, accept_update_with_no_id: false, &block)
|
65
65
|
fatal "Can't create job named '#{name}' because it already exists." if exists?(name)
|
66
66
|
|
67
|
-
Batch::Job.new(enviro, name: name, type: type, sets: sets, usecase: usecase).tap do |job|
|
67
|
+
Batch::Job.new(enviro, name: name, type: type, sets: sets, usecase: usecase, accept_update_with_no_id: accept_update_with_no_id).tap do |job|
|
68
68
|
add(job, &block)
|
69
69
|
end
|
70
70
|
end
|
data/lib/eco/api/session.rb
CHANGED
@@ -251,8 +251,8 @@ module Eco
|
|
251
251
|
# Shortcut to create a job of certain type within a group
|
252
252
|
# @param [see @Eco::API::Session::Batch::Jobs#new]
|
253
253
|
# @return [Eco::API::Session::Batch::Job]
|
254
|
-
def new_job(group, name, type, usecase, sets = [:core, :details, :account], &block)
|
255
|
-
job_group(group).new(name, usecase: usecase, type: type, sets: sets, &block)
|
254
|
+
def new_job(group, name, type, usecase, sets = [:core, :details, :account], accept_update_with_no_id = false, &block)
|
255
|
+
job_group(group).new(name, usecase: usecase, type: type, sets: sets, accept_update_with_no_id: accept_update_with_no_id, &block)
|
256
256
|
end
|
257
257
|
|
258
258
|
# @see Eco::API::Session::Batch::JobsGroups#launch
|
@@ -70,8 +70,14 @@ class Eco::API::UseCases::OozeSamples::OozeBaseCase < Eco::API::Common::Loaders:
|
|
70
70
|
|
71
71
|
def with_fields(entry = target, type: nil, label: nil)
|
72
72
|
flds = entry.components
|
73
|
-
|
74
|
-
|
73
|
+
if type
|
74
|
+
if flds.respond_to?(:get_by_type)
|
75
|
+
flds = flds.get_by_type(type)
|
76
|
+
else
|
77
|
+
flds = flds.select {|fld| fld.type == type}
|
78
|
+
end
|
79
|
+
end
|
80
|
+
flds.select do |fld|
|
75
81
|
value = (label == :unnamed) ? nil : label
|
76
82
|
!label || same_string?(fld.label, value)
|
77
83
|
end.each do |field|
|
@@ -160,6 +160,7 @@ class Eco::API::UseCases::OozeSamples::RegisterMigrationCase < Eco::API::UseCase
|
|
160
160
|
if !options[:dry_run]
|
161
161
|
create_ooze(draft, template_id: from).page_id
|
162
162
|
else
|
163
|
+
logger.info("Creation sample follows...")
|
163
164
|
dry_run_feedback(draft)
|
164
165
|
false
|
165
166
|
end
|
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.9
|
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.7
|
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.7
|
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.11
|
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.11
|
170
170
|
- - "<"
|
171
171
|
- !ruby/object:Gem::Version
|
172
172
|
version: '0.2'
|