eco-helpers 2.0.37 → 2.0.41
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 +38 -1
- data/eco-helpers.gemspec +1 -1
- data/lib/eco/api/session/batch/job.rb +2 -1
- data/lib/eco/api/usecases/ooze_samples/ooze_base_case.rb +47 -0
- data/lib/eco/api/usecases/ooze_samples/ooze_update_case.rb +0 -39
- data/lib/eco/api/usecases/ooze_samples/register_update_case.rb +2 -2
- data/lib/eco/cli/config/default/workflow.rb +19 -7
- data/lib/eco/csv/table.rb +40 -0
- data/lib/eco/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3f9f409fadb3cd263964b4254d35ea3b32cd97ff21eaaef4cd96bb0bafb61b83
|
4
|
+
data.tar.gz: 411187eb287a25f73e75d08fd7ccc6984e3ece935786fd161f3998cfb53a0670
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7ef199c58c422283f767f90319e6768265a2d38b33e4b5be73ad6b3c77923949056e5263e2130b650307d08deb78d4e0e1da078fcfed70936cb294aa8bb1326f
|
7
|
+
data.tar.gz: aee328dc5617c180ca6efc8e7399a205755b4abb6ff0b8546f19462e2d3a2f095bcc7be6d3b43eb2303b99710fd3bcc881c4421560a37d91b4b0a743bc6e3db6
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,43 @@
|
|
1
1
|
# Change Log
|
2
2
|
All notable changes to this project will be documented in this file.
|
3
3
|
|
4
|
+
## [2.0.41] - 2021-09-xx
|
5
|
+
|
6
|
+
### Added
|
7
|
+
### Changed
|
8
|
+
### Fixed
|
9
|
+
- `Eco::API::Session::Batch::Job` `backup_update`
|
10
|
+
- Saved `requests` filename was overlapping due to only batch job type being used
|
11
|
+
- Now it uses the name of the batch job as well
|
12
|
+
|
13
|
+
## [2.0.40] - 2021-09-29
|
14
|
+
|
15
|
+
### Added
|
16
|
+
- Unique access point for `validation` via core case `Eco::API::UseCases::OozeSamples::OozeBaseCase#update_ooze`
|
17
|
+
|
18
|
+
## [2.0.39] - 2021-09-28
|
19
|
+
|
20
|
+
### Changed
|
21
|
+
- `Eco::API::UseCases::OozeSamples::OozeBaseCase`
|
22
|
+
- Moved helpers from `Eco::API::UseCases::OozeSamples::OozeUpdateCase`
|
23
|
+
|
24
|
+
### Fixed
|
25
|
+
- `Eco::API::UseCases::OozeSamples::RegisterUpdateCase`
|
26
|
+
- fix launch condition to be `Y`
|
27
|
+
- fix `search` method call
|
28
|
+
- Changed the `workflow` to prevent re-cache of people when `people` was not used
|
29
|
+
|
30
|
+
## [2.0.38] - 2021-09-07
|
31
|
+
|
32
|
+
### Added
|
33
|
+
- `Eco::CSV::Table` some more helpers to manage input `csv`s
|
34
|
+
- `#transform_headers` that allows to pass a block to decide the new name
|
35
|
+
- `#merge_same_header_names` that allows to deal with value of columns with same header name
|
36
|
+
- `#duplicated_header_names` that identifies repeated header names
|
37
|
+
|
38
|
+
### Changed
|
39
|
+
- Changed the `workflow` to prevent re-cache of people when `people` was not used
|
40
|
+
|
4
41
|
## [2.0.37] - 2021-09-03
|
5
42
|
|
6
43
|
### Added
|
@@ -12,7 +49,7 @@ All notable changes to this project will be documented in this file.
|
|
12
49
|
- stop downloading the people manager
|
13
50
|
- `Eco::API::UseCases::OozeSamples::RegisterUpdateCase`
|
14
51
|
- prevent queuing non page objects
|
15
|
-
|
52
|
+
|
16
53
|
## [2.0.36] - 2021-08-31
|
17
54
|
|
18
55
|
### Fixed
|
data/eco-helpers.gemspec
CHANGED
@@ -31,7 +31,7 @@ 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.3', '< 0.9'
|
34
|
-
spec.add_dependency 'ecoportal-api-v2', '>= 0.8.
|
34
|
+
spec.add_dependency 'ecoportal-api-v2', '>= 0.8.19', '< 0.9'
|
35
35
|
spec.add_dependency 'aws-sdk-s3', '>= 1.83.0', '< 2'
|
36
36
|
spec.add_dependency 'aws-sdk-ses', '>= 1.36.0', '< 2'
|
37
37
|
spec.add_dependency 'dotenv', '>= 2.7.6', '< 2.8'
|
@@ -343,7 +343,8 @@ module Eco
|
|
343
343
|
def backup_update(requests, simulate: false)
|
344
344
|
dry_run = simulate ? "_dry_run" : ""
|
345
345
|
dir = config.people.requests_folder
|
346
|
-
|
346
|
+
filename = name.split(" ").join("-").gsub(/[=\\\/><,"-]+/,"_")
|
347
|
+
file = File.join(dir, "#{type}_data_#{filename}#{dry_run}.json")
|
347
348
|
file_manager.save_json(requests, file, :timestamp)
|
348
349
|
end
|
349
350
|
|
@@ -26,6 +26,48 @@ class Eco::API::UseCases::OozeSamples::OozeBaseCase < Eco::API::Common::Loaders:
|
|
26
26
|
update_ooze(ooze)
|
27
27
|
end
|
28
28
|
|
29
|
+
protected
|
30
|
+
|
31
|
+
def add_field(name, type, section, after: nil, before: nil, side: :left)
|
32
|
+
unless section.is_a?(Ecoportal::API::V2::Page::Section)
|
33
|
+
raise "You need to specify a section for a new field. Given: #{section.class}"
|
34
|
+
end
|
35
|
+
target.components.add(label: name, type: type) do |field|
|
36
|
+
section.add_component(field, after: after, before: before, side: side)
|
37
|
+
end.tap do |field|
|
38
|
+
yield(field) if block_given?
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def with_fields(type: nil, label: nil)
|
43
|
+
flds = target.components
|
44
|
+
flds = flds.get_by_type(type) if type
|
45
|
+
flds = flds.select do |fld|
|
46
|
+
value = (label == :unnamed) ? nil : label
|
47
|
+
!label || same_string?(fld.label, value)
|
48
|
+
end.each do |field|
|
49
|
+
yield(field) if block_given?
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def with_sections(type: nil, heading: nil)
|
54
|
+
secs = target.sections
|
55
|
+
secs = secs.get_by_type(type) if type
|
56
|
+
secs = secs.select do |sec|
|
57
|
+
value = (heading == :unnamed) ? nil : heading
|
58
|
+
!heading || same_string?(sec.heading, value)
|
59
|
+
end.each do |sec|
|
60
|
+
yield(sec) if block_given?
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def with_stage(name:)
|
65
|
+
if stage = target.stages.get_by_name(name)
|
66
|
+
yield(stage) if block_given?
|
67
|
+
end
|
68
|
+
stage
|
69
|
+
end
|
70
|
+
|
29
71
|
private
|
30
72
|
|
31
73
|
# Hook method to use before the target is switched
|
@@ -70,6 +112,11 @@ class Eco::API::UseCases::OozeSamples::OozeBaseCase < Eco::API::Common::Loaders:
|
|
70
112
|
def update_ooze(ooze = target)
|
71
113
|
if !options[:simulate]
|
72
114
|
return unless dirty?(ooze)
|
115
|
+
|
116
|
+
ooze.validate.tap do |validation|
|
117
|
+
raise validation if validation.is_a?(String)
|
118
|
+
end
|
119
|
+
|
73
120
|
apiv2.pages.update(ooze).tap do |response|
|
74
121
|
if response.success?
|
75
122
|
ooze.consolidate!
|
@@ -4,44 +4,6 @@ class Eco::API::UseCases::OozeSamples::OozeUpdateCase < Eco::API::UseCases::Ooze
|
|
4
4
|
|
5
5
|
private
|
6
6
|
|
7
|
-
def with_fields(type: nil, label: nil)
|
8
|
-
flds = target.components
|
9
|
-
flds = flds.get_by_type(type) if type
|
10
|
-
flds = flds.select do |fld|
|
11
|
-
value = (label == :unnamed) ? nil : label
|
12
|
-
!label || same_string?(fld.label, value)
|
13
|
-
end.each do |field|
|
14
|
-
yield(field) if block_given?
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
def with_sections(type: nil, heading: nil)
|
19
|
-
secs = target.sections
|
20
|
-
secs = secs.get_by_type(type) if type
|
21
|
-
secs = secs.select do |sec|
|
22
|
-
value = (heading == :unnamed) ? nil : heading
|
23
|
-
!heading || same_string?(sec.heading, value)
|
24
|
-
end.each do |sec|
|
25
|
-
yield(sec) if block_given?
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
def with_stage(name:)
|
30
|
-
if stage = target.stages.get_by_name(name)
|
31
|
-
yield(stage) if block_given?
|
32
|
-
end
|
33
|
-
stage
|
34
|
-
end
|
35
|
-
|
36
|
-
def add_field(name, type, section, after: nil, side: :left)
|
37
|
-
raise "You need to specify a section for a new field. Given: #{section.class}" unless section.is_a?(Ecoportal::API::V2::Page::Section)
|
38
|
-
target.components.add(label: name, type: type) do |field|
|
39
|
-
section.add_component(field, after: after, side: side)
|
40
|
-
end.tap do |field|
|
41
|
-
yield(field) if block_given?
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
7
|
def to_field(value)
|
46
8
|
fld = nil
|
47
9
|
fld ||= value if value.is_a?(Ecoportal::API::V2::Page::Component)
|
@@ -50,5 +12,4 @@ class Eco::API::UseCases::OozeSamples::OozeUpdateCase < Eco::API::UseCases::Ooze
|
|
50
12
|
#fld ||= value.reference if value.is_a?(Ecoportal::API::V2::Page::Force::Binding)
|
51
13
|
end
|
52
14
|
|
53
|
-
|
54
15
|
end
|
@@ -129,7 +129,7 @@ class Eco::API::UseCases::OozeSamples::RegisterUpdateCase < Eco::API::UseCases::
|
|
129
129
|
apiv2.registers.search(register_id, search_options.merge(only_first: true)).tap do |search_results|
|
130
130
|
str_results = "Total target entries: #{search_results.total} (out of #{search_results.total_before_filtering})"
|
131
131
|
session.prompt_user("Do you want to proceed (y/N):", explanation: str_results, default: "N", timeout: 10) do |res|
|
132
|
-
|
132
|
+
unless res.upcase.start_with?("Y")
|
133
133
|
puts "..."
|
134
134
|
logger.info "Aborting script..."
|
135
135
|
exit(0)
|
@@ -142,7 +142,7 @@ class Eco::API::UseCases::OozeSamples::RegisterUpdateCase < Eco::API::UseCases::
|
|
142
142
|
@search_options ||= {}.tap do |opts|
|
143
143
|
opts.merge!(sort: "created_at")
|
144
144
|
opts.merge!(dir: "asc")
|
145
|
-
opts.merge!(query:
|
145
|
+
opts.merge!(query: conf_search) if conf_search
|
146
146
|
opts.merge!(filters: conf_filters)
|
147
147
|
end
|
148
148
|
end
|
@@ -101,19 +101,28 @@ ASSETS.cli.config do |config|
|
|
101
101
|
get_people = io.options.dig(:people, :get)
|
102
102
|
partial_update = get_people && get_people.dig(:type) == :partial
|
103
103
|
run_it = !io.options[:dry_run] || io.options.dig(:post_launch, :run)
|
104
|
-
|
105
|
-
|
104
|
+
refresh_data = !io.options[:dry_run] && partial_update
|
105
|
+
if run_it
|
106
|
+
if refresh_data
|
106
107
|
# get target people afresh
|
107
108
|
people = io.session.micro.people_refresh(people: io.people, include_created: true)
|
108
109
|
io = io.base.new(people: people)
|
110
|
+
else
|
111
|
+
msg = "Although there are post_launch cases, data will not be refreshed before their run"
|
112
|
+
if io.options[:dry_run]
|
113
|
+
msg += ", because we are in dry-run (simulate)."
|
114
|
+
elsif !partial_update
|
115
|
+
msg += ", because it is not a partial update (-get-partial option not present)."
|
116
|
+
end
|
117
|
+
io.session.logger.warn(msg)
|
109
118
|
end
|
110
119
|
else
|
111
120
|
wf_post.skip!
|
112
121
|
msg = "Although there are post_launch cases, they will NOT be RUN"
|
113
|
-
if
|
114
|
-
msg+= ", because we are in dry-run (simulate)."
|
115
|
-
elsif !partial_update
|
122
|
+
if !partial_update
|
116
123
|
msg+= ", because it is not a partial update (-get-partial)"
|
124
|
+
elsif io.options[:dry_run]
|
125
|
+
msg+= ", because we are in dry-run (simulate)."
|
117
126
|
end
|
118
127
|
io.session.logger.info(msg)
|
119
128
|
end
|
@@ -146,8 +155,11 @@ ASSETS.cli.config do |config|
|
|
146
155
|
get_people = io.options.dig(:people, :get)
|
147
156
|
partial_update = get_people && get_people.dig(:type) == :partial
|
148
157
|
unless !io.options[:end_get] || io.options[:dry_run] || partial_update
|
149
|
-
people
|
150
|
-
|
158
|
+
# Prevent getting people when there were no use cases that used them
|
159
|
+
unless io.people
|
160
|
+
people = io.session.micro.people_cache
|
161
|
+
io = io.new(people: people)
|
162
|
+
end
|
151
163
|
end
|
152
164
|
io
|
153
165
|
end
|
data/lib/eco/csv/table.rb
CHANGED
@@ -15,6 +15,46 @@ module Eco
|
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
+
# @return [Eco::CSV::Table]
|
19
|
+
def transform_headers
|
20
|
+
header = self.headers
|
21
|
+
cols = self.columns
|
22
|
+
cols.each do |col|
|
23
|
+
col[0] = yield(col.first)
|
24
|
+
end
|
25
|
+
columns_to_table(cols)
|
26
|
+
end
|
27
|
+
|
28
|
+
# @return [Eco::CSV::Table]
|
29
|
+
def merge_same_header_names
|
30
|
+
dups = self.duplicated_header_names
|
31
|
+
out_rows = self.map do |row|
|
32
|
+
row.to_a.each_with_object({}) do |(name, value), out|
|
33
|
+
if dups.include?(name) && out.key?(name)
|
34
|
+
if block_given?
|
35
|
+
yield(value, out[name], name)
|
36
|
+
else
|
37
|
+
# resolve
|
38
|
+
value || out[name]
|
39
|
+
end
|
40
|
+
elsif out.key?(name)
|
41
|
+
out[name]
|
42
|
+
else
|
43
|
+
value
|
44
|
+
end.tap do |final_value|
|
45
|
+
out[name] = final_value
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
self.class.new(out_rows)
|
50
|
+
end
|
51
|
+
|
52
|
+
# @return [Array<String>] list of duplicated header names
|
53
|
+
def duplicated_header_names
|
54
|
+
header = self.headers
|
55
|
+
header.select {|e| header.count(e) > 1}.uniq
|
56
|
+
end
|
57
|
+
|
18
58
|
# @return [Eco::CSV::Table]
|
19
59
|
def transform_values
|
20
60
|
transformed_rows = rows.map do |row|
|
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.0.
|
4
|
+
version: 2.0.41
|
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.8.
|
139
|
+
version: 0.8.19
|
140
140
|
- - "<"
|
141
141
|
- !ruby/object:Gem::Version
|
142
142
|
version: '0.9'
|
@@ -146,7 +146,7 @@ dependencies:
|
|
146
146
|
requirements:
|
147
147
|
- - ">="
|
148
148
|
- !ruby/object:Gem::Version
|
149
|
-
version: 0.8.
|
149
|
+
version: 0.8.19
|
150
150
|
- - "<"
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: '0.9'
|