eco-helpers 2.7.2 → 2.7.4
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 +23 -3
- data/eco-helpers.gemspec +1 -1
- data/lib/eco/api/common/loaders/base.rb +4 -3
- data/lib/eco/api/common/loaders/config/workflow/mailer.rb +2 -2
- data/lib/eco/api/common/loaders/parser.rb +1 -0
- data/lib/eco/api/common/people/default_parsers/csv_parser.rb +47 -33
- data/lib/eco/api/common/people/default_parsers/login_providers_parser.rb +1 -1
- data/lib/eco/api/common/people/default_parsers/xls_parser.rb +8 -2
- data/lib/eco/api/common/people/default_parsers.rb +0 -11
- data/lib/eco/api/common/people/person_attribute_parser.rb +2 -1
- data/lib/eco/api/common/people/person_entry.rb +4 -2
- data/lib/eco/api/session/batch/errors.rb +43 -44
- data/lib/eco/api/session.rb +9 -2
- data/lib/eco/api/usecases/default/locations/csv_to_tree_case.rb +1 -1
- data/lib/eco/api/usecases/default/people/set_default_tag_case.rb +2 -2
- data/lib/eco/api/usecases/default/people/supers_cyclic_identify_case.rb +15 -17
- data/lib/eco/api/usecases/default/people/switch_supervisor_case.rb +26 -20
- data/lib/eco/api/usecases/default/people/transfer_account_case.rb +86 -70
- data/lib/eco/api/usecases/default_cases/hris_case.rb +1 -1
- data/lib/eco/api/usecases/default_cases/to_csv_case.rb +7 -7
- data/lib/eco/api/usecases/graphql/helpers/location/command.rb +1 -1
- data/lib/eco/api/usecases/graphql/samples/location/command/service/tree_update.rb +73 -65
- data/lib/eco/api/usecases/graphql/samples/location/service/tree_diff.rb +7 -1
- data/lib/eco/api/usecases/graphql/samples/location/service/tree_to_list/output.rb +1 -0
- data/lib/eco/api/usecases/graphql/samples/location/service/tree_to_list.rb +1 -0
- data/lib/eco/api/usecases/ooze_cases/export_register_case.rb +1 -1
- data/lib/eco/api/usecases/ooze_samples/ooze_base_case.rb +13 -9
- data/lib/eco/api/usecases/ooze_samples/ooze_run_base_case.rb +4 -4
- data/lib/eco/api/usecases/ooze_samples/register_export_case.rb +9 -6
- data/lib/eco/api/usecases/ooze_samples/register_migration_case.rb +5 -5
- data/lib/eco/api/usecases/ooze_samples/register_update_case.rb +7 -5
- data/lib/eco/api/usecases/ooze_samples/target_oozes_update_case.rb +2 -2
- data/lib/eco/api/usecases.rb +19 -13
- data/lib/eco/cli/scripting/args_helpers.rb +2 -0
- data/lib/eco/data/files/helpers.rb +25 -12
- data/lib/eco/data/hashes/sanke_camel_indifferent_access.rb +0 -5
- data/lib/eco/language/models/parser_serializer.rb +4 -2
- 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: f5417454380ab9a37757721abd2b66a9097eac191ae435336fb436caeabfac49
|
4
|
+
data.tar.gz: fe83f4f50b5053050f8ff15dd43c224130a8e0bb7ece5e44aaa8e91f20c7ab77
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8576cbd86fadc000127e2f83396e5cbf2d4b7196150fe3a7ff78c3ce987850ebe73758622678492811350434981cfa1962796dc847b39475e80b8ef61e09c6da
|
7
|
+
data.tar.gz: c6517c924dee344f9445e7213c404f7295f45ff9c41ff45b2fbad437becfd2ea8aaadc95b82b2e0189e0ade9bef299826f56910704a16954a59c0a91930133bb
|
data/CHANGELOG.md
CHANGED
@@ -1,14 +1,34 @@
|
|
1
1
|
# Change Log
|
2
2
|
All notable changes to this project will be documented in this file.
|
3
3
|
|
4
|
-
## [2.7.
|
4
|
+
## [2.7.5] - 2024-05-xx
|
5
5
|
|
6
6
|
### Added
|
7
|
-
|
8
|
-
|
7
|
+
### Changed
|
8
|
+
### Fixed
|
9
|
+
- Loading of tree diff / update service
|
10
|
+
|
11
|
+
## [2.7.4] - 2024-05-07
|
12
|
+
|
13
|
+
### Fixed
|
14
|
+
- Loading of tree diff / update service
|
15
|
+
|
16
|
+
## [2.7.3] - 2024-05-07
|
9
17
|
|
10
18
|
### Changed
|
19
|
+
- upgraded `ecoportal-api-graphql`
|
20
|
+
- Mailer
|
21
|
+
- heading of errors and warnings: added **ALL** to state clearly that all warnings and errors come thereon
|
22
|
+
- Batch Errors: removed _batch_ wording, as it refers to a single action in the batch
|
23
|
+
|
11
24
|
### Fixed
|
25
|
+
- Tree diff helpers loading (load as if concern)
|
26
|
+
|
27
|
+
## [2.7.2] - 2024-04-23
|
28
|
+
|
29
|
+
### Added
|
30
|
+
- **Parsers**
|
31
|
+
- Native **number parser**, added _warning_ when number cannot be parsed
|
12
32
|
|
13
33
|
## [2.7.1] - 2024-04-23
|
14
34
|
|
data/eco-helpers.gemspec
CHANGED
@@ -32,7 +32,7 @@ Gem::Specification.new do |spec|
|
|
32
32
|
|
33
33
|
spec.add_dependency 'ecoportal-api', '>= 0.9.7', '< 0.10'
|
34
34
|
spec.add_dependency 'ecoportal-api-v2', '>= 1.1.8', '< 1.2'
|
35
|
-
spec.add_dependency 'ecoportal-api-graphql', '>= 0.3.
|
35
|
+
spec.add_dependency 'ecoportal-api-graphql', '>= 0.3.16', '< 0.4'
|
36
36
|
spec.add_dependency 'aws-sdk-s3', '>= 1.142.0', '< 2'
|
37
37
|
spec.add_dependency 'aws-sdk-ses', '>= 1.58.0', '< 2'
|
38
38
|
spec.add_dependency 'dotenv', '>= 2.8.1', '< 3'
|
@@ -48,7 +48,7 @@ class Eco::API::Common::Loaders::Workflow::Mailer < Eco::API::Common::Loaders::W
|
|
48
48
|
end
|
49
49
|
|
50
50
|
def some_update?(io)
|
51
|
-
cli.config.usecases.active(io: io).any? do |usecase,
|
51
|
+
cli.config.usecases.active(io: io).any? do |usecase, _data|
|
52
52
|
%i[transform sync].any? { |type| usecase.type == type }
|
53
53
|
end
|
54
54
|
end
|
@@ -64,7 +64,7 @@ class Eco::API::Common::Loaders::Workflow::Mailer < Eco::API::Common::Loaders::W
|
|
64
64
|
def log_err_n_warn(io)
|
65
65
|
warn_errors = io.logger.cache.logs(level: %i[error warn])
|
66
66
|
return if warn_errors.empty?
|
67
|
-
"WARNINGS & ERRORS:\n#{warn_errors.join
|
67
|
+
"ALL WARNINGS & ERRORS:\n#{warn_errors.join}\n"
|
68
68
|
end
|
69
69
|
|
70
70
|
def error_message
|
@@ -14,7 +14,7 @@ class Eco::API::Common::People::DefaultParsers::CSVParser < Eco::API::Common::Lo
|
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
-
def serializer(array_hash,
|
17
|
+
def serializer(array_hash, _deps)
|
18
18
|
arr_rows = []
|
19
19
|
unless array_hash.empty?
|
20
20
|
header = array_hash.first.keys
|
@@ -27,19 +27,22 @@ class Eco::API::Common::People::DefaultParsers::CSVParser < Eco::API::Common::Lo
|
|
27
27
|
|
28
28
|
private
|
29
29
|
|
30
|
-
def abort(
|
31
|
-
|
32
|
-
exit(1)
|
30
|
+
def abort(msg)
|
31
|
+
super(msg, raising: false)
|
33
32
|
end
|
34
33
|
|
35
34
|
def require_headers!(table)
|
36
35
|
headers = table.headers
|
37
|
-
|
36
|
+
|
37
|
+
abort("Missing headers in CSV") unless headers&.any?
|
38
|
+
|
38
39
|
empty = []
|
39
40
|
headers.each_with_index do |header, idx|
|
40
41
|
empty << idx if header.to_s.strip.empty?
|
41
42
|
end
|
42
|
-
|
43
|
+
|
44
|
+
abort("Empty headers in column(s): #{empty.join(', ')}") if empty.any?
|
45
|
+
|
43
46
|
true
|
44
47
|
end
|
45
48
|
|
@@ -58,12 +61,13 @@ class Eco::API::Common::People::DefaultParsers::CSVParser < Eco::API::Common::Lo
|
|
58
61
|
end
|
59
62
|
|
60
63
|
def null?(value)
|
61
|
-
return true
|
64
|
+
return true unless value
|
65
|
+
|
62
66
|
str = value.strip.upcase
|
63
67
|
["NULL"].any? {|token| str == token}
|
64
68
|
end
|
65
69
|
|
66
|
-
def check_headers(table)
|
70
|
+
def check_headers(table) # rubocop:disable Metrics/AbcSize
|
67
71
|
headers = table.headers
|
68
72
|
unmatch = []
|
69
73
|
unmatch = unmatched_headers(headers) if options.dig(:input, :header_check, :order)
|
@@ -72,7 +76,7 @@ class Eco::API::Common::People::DefaultParsers::CSVParser < Eco::API::Common::Lo
|
|
72
76
|
criteria = [unknown, missing[:direct], missing[:indirect], unmatch]
|
73
77
|
return if criteria.all?(&:empty?)
|
74
78
|
|
75
|
-
msg
|
79
|
+
msg = "Detected possible HEADER ISSUES !!!\n"
|
76
80
|
|
77
81
|
# requires exact match
|
78
82
|
unless unmatch.empty?
|
@@ -86,9 +90,11 @@ class Eco::API::Common::People::DefaultParsers::CSVParser < Eco::API::Common::Lo
|
|
86
90
|
msg << " - #{missed.join("\n - ")}\n"
|
87
91
|
end
|
88
92
|
end
|
93
|
+
|
89
94
|
msg << "Missing or Wrong HEADER names in the CSV file:\n"
|
90
95
|
msg << " * UNKNOWN (or not used?): #{unknown}\n" unless unknown.empty?
|
91
96
|
msg << " * MISSING HEADER: #{missing[:direct]}\n" unless missing[:direct].empty?
|
97
|
+
|
92
98
|
unless (data = missing[:indirect]).empty?
|
93
99
|
msg << " * MISSING INDIRECTLY:\n"
|
94
100
|
data.each do |ext, info|
|
@@ -99,13 +105,16 @@ class Eco::API::Common::People::DefaultParsers::CSVParser < Eco::API::Common::Lo
|
|
99
105
|
elsif status == :active
|
100
106
|
"there could be missing info in: #{attrs}"
|
101
107
|
end
|
102
|
-
end.compact.join("; ")
|
108
|
+
end.compact.join("; ")
|
109
|
+
msg << "\n"
|
103
110
|
end
|
104
111
|
end
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
112
|
+
|
113
|
+
log(:warn) { msg }
|
114
|
+
|
115
|
+
msg = "There were issues identified on the CSV header names. Aborting..."
|
116
|
+
abort(msg) if options.dig(:input, :header_check, :must_be_valid)
|
117
|
+
|
109
118
|
sleep(2)
|
110
119
|
end
|
111
120
|
|
@@ -119,13 +128,14 @@ class Eco::API::Common::People::DefaultParsers::CSVParser < Eco::API::Common::Lo
|
|
119
128
|
(headers - known_headers) - all_internal_attrs
|
120
129
|
end
|
121
130
|
|
122
|
-
def missing_headers(headers)
|
131
|
+
def missing_headers(headers) # rubocop:disable Metrics/AbcSize
|
123
132
|
int_head = internal_present_or_active(headers)
|
124
|
-
|
133
|
+
external = headers.select do |e|
|
125
134
|
i = fields_mapper.to_internal(e)
|
126
135
|
int_head.include?(i)
|
127
136
|
end
|
128
|
-
|
137
|
+
|
138
|
+
ext_present = known_headers_present(int_head) | external
|
129
139
|
ext_miss = known_headers - ext_present
|
130
140
|
|
131
141
|
{
|
@@ -133,7 +143,8 @@ class Eco::API::Common::People::DefaultParsers::CSVParser < Eco::API::Common::Lo
|
|
133
143
|
indirect: {}
|
134
144
|
}.tap do |missing|
|
135
145
|
ext_miss.each do |ext|
|
136
|
-
next unless int = fields_mapper.to_internal(ext)
|
146
|
+
next unless (int = fields_mapper.to_internal(ext))
|
147
|
+
|
137
148
|
missing[:direct] << ext if all_internal_attrs.include?(int)
|
138
149
|
related_attrs_requirements = required_attrs.values.select do |req|
|
139
150
|
dep = req.dependant?(int)
|
@@ -141,10 +152,13 @@ class Eco::API::Common::People::DefaultParsers::CSVParser < Eco::API::Common::Lo
|
|
141
152
|
in_header = int_head.include?(req.attr)
|
142
153
|
affects || (dep && !in_header)
|
143
154
|
end
|
155
|
+
|
144
156
|
next if related_attrs_requirements.empty?
|
157
|
+
|
145
158
|
data = missing[:indirect][ext] = {}
|
146
159
|
data[:int] = int
|
147
160
|
data[:attrs] = {}
|
161
|
+
|
148
162
|
related_attrs_requirements.each_with_object(data[:attrs]) do |req, attrs|
|
149
163
|
status = req.active?(*int_head) ? :active : :inactive
|
150
164
|
attrs[status] ||= []
|
@@ -155,32 +169,33 @@ class Eco::API::Common::People::DefaultParsers::CSVParser < Eco::API::Common::Lo
|
|
155
169
|
end
|
156
170
|
|
157
171
|
def known_headers_present(headers_internal)
|
158
|
-
|
172
|
+
known_headers.select do |ext|
|
159
173
|
int = fields_mapper.to_internal(ext)
|
160
174
|
headers_internal.include?(int)
|
161
175
|
end
|
162
176
|
end
|
163
177
|
|
164
178
|
# Scopes what internal attrs appear in headers as they are
|
165
|
-
def internal_present_or_active(headers, inactive_requirements = {})
|
179
|
+
def internal_present_or_active(headers, inactive_requirements = {}) # rubocop:disable Metrics/AbcSize
|
166
180
|
# internal attrs that are not being mapped
|
167
|
-
int_all
|
168
|
-
hint
|
169
|
-
hext
|
181
|
+
int_all = all_internal_attrs.reject {|i| fields_mapper.external?(i)}
|
182
|
+
hint = headers & int_all
|
183
|
+
hext = headers - hint
|
170
184
|
int_present = hint + hext.map {|e| fields_mapper.to_internal(e)}.compact
|
171
185
|
|
172
|
-
update_inactive =
|
186
|
+
update_inactive = proc do
|
173
187
|
inactive_requirements.dup.each do |attr, req|
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
188
|
+
next unless req.active?(*int_present)
|
189
|
+
|
190
|
+
inactive_requirements.delete(attr)
|
191
|
+
int_present << attr
|
192
|
+
update_inactive.call
|
179
193
|
end
|
180
194
|
end
|
181
195
|
|
182
|
-
required_attrs.
|
196
|
+
required_attrs.each_value do |req|
|
183
197
|
next if int_present.include?(req)
|
198
|
+
|
184
199
|
if req.active?(*int_present)
|
185
200
|
inactive_requirements.delete(req.attr)
|
186
201
|
int_present << req.attr
|
@@ -189,6 +204,7 @@ class Eco::API::Common::People::DefaultParsers::CSVParser < Eco::API::Common::Lo
|
|
189
204
|
inactive_requirements[req.attr] = req
|
190
205
|
end
|
191
206
|
end
|
207
|
+
|
192
208
|
int_present
|
193
209
|
end
|
194
210
|
|
@@ -202,9 +218,7 @@ class Eco::API::Common::People::DefaultParsers::CSVParser < Eco::API::Common::Lo
|
|
202
218
|
end
|
203
219
|
|
204
220
|
def required_attrs
|
205
|
-
@required_attrs ||= person_parser.required_attrs.
|
206
|
-
out[ra.attr] = ra
|
207
|
-
end
|
221
|
+
@required_attrs ||= person_parser.required_attrs.to_h {|ra| [ra.attr, ra]}
|
208
222
|
end
|
209
223
|
|
210
224
|
def all_internal_attrs
|
@@ -8,7 +8,7 @@ class Eco::API::Common::People::DefaultParsers::LoginProvidersParser < Eco::API:
|
|
8
8
|
login_providers.to_id(name&.downcase&.strip).tap do |known|
|
9
9
|
unless !name || known || unknown_pgs.include?(name)
|
10
10
|
unknown_pgs.push(name)
|
11
|
-
|
11
|
+
log(:warn) { "Unknown Login Provider: '#{name}'" }
|
12
12
|
end
|
13
13
|
end
|
14
14
|
end.compact
|
@@ -29,7 +29,9 @@ class Eco::API::Common::People::DefaultParsers::XLSParser < Eco::API::Common::Lo
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def headers
|
32
|
-
|
32
|
+
log(:warn) {
|
33
|
+
"Headers detection is using your fields_map.json file (native behaviour)"
|
34
|
+
}
|
33
35
|
session.fields_mapper.list(:external).uniq
|
34
36
|
end
|
35
37
|
|
@@ -50,7 +52,11 @@ class Eco::API::Common::People::DefaultParsers::XLSParser < Eco::API::Common::Lo
|
|
50
52
|
spreadheet.parse(header_search: target, clean: true)
|
51
53
|
rescue Roo::HeaderRowNotFoundError => e
|
52
54
|
missing = JSON.parse(e.message)
|
53
|
-
|
55
|
+
|
56
|
+
log(:warn) {
|
57
|
+
"The input file is missing these headers: #{missing}"
|
58
|
+
}
|
59
|
+
|
54
60
|
present = target - missing
|
55
61
|
rows(present)
|
56
62
|
end
|
@@ -6,17 +6,6 @@ module Eco
|
|
6
6
|
class DefaultParsers < PersonParser
|
7
7
|
autoloads_children_of "Eco::API::Common::Loaders::Parser"
|
8
8
|
autoload_namespace "Eco::API::Common::People::DefaultParsers"
|
9
|
-
|
10
|
-
def initialize(**kargs)
|
11
|
-
super(**kargs)
|
12
|
-
define_defaults
|
13
|
-
end
|
14
|
-
|
15
|
-
private
|
16
|
-
|
17
|
-
def define_defaults
|
18
|
-
# SelectParser.new(self, select_hashes: select_tables).process
|
19
|
-
end
|
20
9
|
end
|
21
10
|
end
|
22
11
|
end
|
@@ -77,7 +77,8 @@ module Eco
|
|
77
77
|
end
|
78
78
|
|
79
79
|
# Helper to obtain the current internal named attributes of the data
|
80
|
-
# @param source_data [Array<String>, Hash] if `Array` those are already the `keys`,
|
80
|
+
# @param source_data [Array<String>, Hash] if `Array` those are already the `keys`,
|
81
|
+
# if `Hash` it gets the `keys`
|
81
82
|
# @return [Array<String>] `keys` of `source_data`
|
82
83
|
def data_keys(source_data)
|
83
84
|
case source_data
|
@@ -5,11 +5,13 @@ module Eco
|
|
5
5
|
class PersonEntry
|
6
6
|
DEBUG = false
|
7
7
|
|
8
|
-
# This class is meant to provide a common interface to access entries of source data that come in
|
8
|
+
# This class is meant to provide a common interface to access entries of source data that come in
|
9
|
+
# different formats.
|
9
10
|
# @note
|
10
11
|
# - if `data` is a `Person` object, its behaviour is `serialise`.
|
11
12
|
# - if `data` is **not** a `Person` object, it does a `parse`.
|
12
|
-
# - currently **in rework**, so there may be subtle differences that make it temporarily unstable
|
13
|
+
# - currently **in rework**, so there may be subtle differences that make it temporarily unstable
|
14
|
+
# (yet it is reliable).
|
13
15
|
# @param data [Hash, Ecoportal::API::V1::Person] `Person` object
|
14
16
|
# to be serialized or hashed entry (`CSV::Row` is accepted).
|
15
17
|
# @param person_parser [Common::People::PersonParser] parser/serializer
|
@@ -4,7 +4,6 @@ module Eco
|
|
4
4
|
class Batch
|
5
5
|
# Helper object linked to a `Batch::Status`. Its aim is to manage the errors of the batch status.
|
6
6
|
class Errors
|
7
|
-
|
8
7
|
# @attr_reader status [Eco::API::Session::Batch::Status] `batch status` this `Errors` object is associated to.
|
9
8
|
attr_reader :status
|
10
9
|
|
@@ -12,7 +11,9 @@ module Eco
|
|
12
11
|
|
13
12
|
# @param status [Eco::API::Session::Batch::Status] `batch status` this `Errors` object is associated to.
|
14
13
|
def initialize(status:)
|
15
|
-
"Expected Batch::Status as root. Given: #{status.class}"
|
14
|
+
msg = "Expected Batch::Status as root. Given: #{status.class}"
|
15
|
+
raise ArgumentError msg unless status.is_a?(Eco::API::Session::Batch::Status)
|
16
|
+
|
16
17
|
@status = status
|
17
18
|
end
|
18
19
|
|
@@ -52,7 +53,8 @@ module Eco
|
|
52
53
|
end
|
53
54
|
|
54
55
|
# Was there any _Sever_ (reply) **error** as a result of this batch?
|
55
|
-
# @return [Boolean] `true` if any of the queried _entries_ got
|
56
|
+
# @return [Boolean] `true` if any of the queried _entries_ got
|
57
|
+
# an unsuccessful `Ecoportal::API::Common::BatchResponse`
|
56
58
|
def any?
|
57
59
|
queue.any? {|query| !status[query].success?}
|
58
60
|
end
|
@@ -62,14 +64,10 @@ module Eco
|
|
62
64
|
# 1. `entries` that got that error, if `only_entries` is `true`
|
63
65
|
# 2. `ErrorCache` objects, if `only_entries` is `false`
|
64
66
|
def by_type(only_entries: true)
|
65
|
-
errors.group_by do |
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
arr.map {|e| e.entry}
|
70
|
-
else
|
71
|
-
arr
|
72
|
-
end
|
67
|
+
errors.group_by(&:type).transform_values do |arr|
|
68
|
+
next arr unless only_entries
|
69
|
+
|
70
|
+
arr.map(&:entry)
|
73
71
|
end
|
74
72
|
end
|
75
73
|
# @!endgroup
|
@@ -83,27 +81,28 @@ module Eco
|
|
83
81
|
def errors
|
84
82
|
entries.each_with_object([]) do |entry, arr|
|
85
83
|
response = status[entry]
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
84
|
+
next unless (body = response.body)
|
85
|
+
|
86
|
+
errs = []
|
87
|
+
case body
|
88
|
+
when Hash
|
89
|
+
body_errs = body["errors"] || body["error"]
|
90
|
+
errs = [body_errs].flatten(1).compact if body_errs
|
91
|
+
|
92
|
+
response_errs = errs.empty? && !response.success?
|
93
|
+
errs = [body["response"]].flatten(1).compact if response_errs
|
94
|
+
when String
|
95
|
+
errs = [body]
|
96
|
+
end
|
97
|
+
|
98
|
+
errs.each do |msg|
|
99
|
+
err_cache = ErrorCache.new(
|
100
|
+
klass = Eco::API::Error.get_type(msg),
|
101
|
+
klass.new(err_msg: msg, entry: entry, session: session),
|
102
|
+
entry,
|
103
|
+
response
|
104
|
+
)
|
105
|
+
arr.push(err_cache)
|
107
106
|
end
|
108
107
|
end
|
109
108
|
end
|
@@ -112,19 +111,19 @@ module Eco
|
|
112
111
|
|
113
112
|
def message
|
114
113
|
msgs = strs
|
115
|
-
if msgs.
|
116
|
-
"There were #{msgs.length} errors:\n" + msgs.join("\n")
|
117
|
-
else
|
114
|
+
if msgs.empty?
|
118
115
|
"There were no errors for the current batch '#{method}'!! ;)"
|
116
|
+
else
|
117
|
+
"There were #{msgs.length} errors:\n" + msgs.join("\n")
|
119
118
|
end
|
120
119
|
end
|
121
120
|
|
122
121
|
def print
|
123
122
|
msgs = strs
|
124
|
-
if msgs.
|
125
|
-
logger.error("There were #{msgs.length} errors:\n" + msgs.join("\n"))
|
126
|
-
else
|
123
|
+
if msgs.empty?
|
127
124
|
logger.info("There were no errors for the current batch '#{method}'!! ;)")
|
125
|
+
else
|
126
|
+
logger.error("There were #{msgs.length} errors:\n" + msgs.join("\n"))
|
128
127
|
end
|
129
128
|
end
|
130
129
|
# @!endgroup
|
@@ -142,12 +141,12 @@ module Eco
|
|
142
141
|
# @return [Array<Hash>, Array<Ecoportal::API::V1::Person>, Array<Ecoportal::API::Internal::Person>]
|
143
142
|
def entries
|
144
143
|
queue.select.with_index do |query, i|
|
145
|
-
unless response = status[i]
|
144
|
+
unless (response = status[i])
|
146
145
|
msg = "Error: query with no response. You might have duplicated entries in your queue.\n"
|
147
146
|
msg += "Queue length: #{queue.length}; Queue elements class: #{queue.first.class}\n"
|
148
147
|
msg += "Query with no response. Person: #{person_ref(query)}\n"
|
149
148
|
queue.map do |entry|
|
150
|
-
if [
|
149
|
+
if %i[id external_id email].any? {|attr| (v = get_attr(entry, attr)) && v == get_attr(query, attr)}
|
151
150
|
msg += "It could be this peson entry (idx: #{to_index(entry)}): #{person_ref(entry)}\n"
|
152
151
|
end
|
153
152
|
end
|
@@ -184,15 +183,15 @@ module Eco
|
|
184
183
|
entry = queue.to_a[i]
|
185
184
|
response = status[i]
|
186
185
|
msg = "Error #{response.status}: #{response.body}\n"
|
187
|
-
msg += "-- Failed to
|
186
|
+
msg += "-- Failed to #{method}. Person: #{person_ref(entry)}"
|
188
187
|
end
|
189
188
|
msg
|
190
189
|
end
|
191
190
|
|
192
191
|
def print_one(key)
|
193
|
-
|
194
|
-
|
195
|
-
|
192
|
+
return if status.success?(key)
|
193
|
+
|
194
|
+
logger.error(str(key))
|
196
195
|
end
|
197
196
|
end
|
198
197
|
end
|
data/lib/eco/api/session.rb
CHANGED
@@ -281,7 +281,7 @@ module Eco
|
|
281
281
|
# Shortcut to create a job of certain type within a group
|
282
282
|
# @param [see @Eco::API::Session::Batch::Jobs#new]
|
283
283
|
# @return [Eco::API::Session::Batch::Job]
|
284
|
-
def new_job(
|
284
|
+
def new_job( # rubocop:disable Metrics/ParameterLists
|
285
285
|
group,
|
286
286
|
name,
|
287
287
|
type,
|
@@ -290,7 +290,14 @@ module Eco
|
|
290
290
|
accept_update_with_no_id = false, # rubocop:disable Style/OptionalBooleanParameter
|
291
291
|
&block
|
292
292
|
)
|
293
|
-
job_group(group).new(
|
293
|
+
job_group(group).new(
|
294
|
+
name,
|
295
|
+
usecase: usecase,
|
296
|
+
type: type,
|
297
|
+
sets: sets,
|
298
|
+
accept_update_with_no_id: accept_update_with_no_id,
|
299
|
+
&block
|
300
|
+
)
|
294
301
|
end
|
295
302
|
|
296
303
|
# @see Eco::API::Session::Batch::JobsGroups#launch
|
@@ -13,7 +13,7 @@ class Eco::API::UseCases::Default::Locations::CsvToTree < Eco::API::Common::Load
|
|
13
13
|
File.open(output_file, "w") do |fd|
|
14
14
|
fd << tree_struct.as_json.to_json
|
15
15
|
end
|
16
|
-
|
16
|
+
log(:info) { "Saved structure in '#{output_file}'" }
|
17
17
|
end
|
18
18
|
|
19
19
|
private
|
@@ -6,7 +6,7 @@ class Eco::API::UseCases::Default::People::SetDefaultTagCase < Eco::API::Common:
|
|
6
6
|
# different options (several nodes at the same depth):
|
7
7
|
# => take the common node between them (i.e. you have Hamilton and Auckland -> take New Zealand)
|
8
8
|
# => if there's no common node between them, take the `first` (unless they are at top level of the tree)
|
9
|
-
def main(
|
9
|
+
def main(_people, session, options, usecase)
|
10
10
|
tagtree_present!
|
11
11
|
users = users_present!
|
12
12
|
update = session.new_job("main", "update", :update, usecase, :account)
|
@@ -22,7 +22,7 @@ class Eco::API::UseCases::Default::People::SetDefaultTagCase < Eco::API::Common:
|
|
22
22
|
def tagtree_present!
|
23
23
|
return unless tagtree?
|
24
24
|
|
25
|
-
msg
|
25
|
+
msg = "There is no locs struct defined. Aborting..."
|
26
26
|
logger.fatal(msg)
|
27
27
|
raise msg
|
28
28
|
end
|
@@ -4,7 +4,7 @@ class Eco::API::UseCases::Default::People::SupersCyclicIdentify < Eco::API::Comm
|
|
4
4
|
|
5
5
|
attr_reader :people
|
6
6
|
|
7
|
-
def main(
|
7
|
+
def main(_people, _session, options, _usecase)
|
8
8
|
options[:end_get] = false
|
9
9
|
save!(cyclic_sets)
|
10
10
|
end
|
@@ -21,25 +21,23 @@ class Eco::API::UseCases::Default::People::SupersCyclicIdentify < Eco::API::Comm
|
|
21
21
|
|
22
22
|
def save!(data)
|
23
23
|
if data.empty?
|
24
|
-
|
24
|
+
log(:info) { "There were no cyclic supervisors identified!!" }
|
25
25
|
return
|
26
26
|
end
|
27
27
|
|
28
28
|
ext = File.extname(file).downcase.delete(".")
|
29
29
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
# create_file(data, file: file, format: :json)
|
42
|
-
end
|
30
|
+
case ext
|
31
|
+
when "txt"
|
32
|
+
create_file(data, file: file, format: :txt)
|
33
|
+
when "html"
|
34
|
+
log(:warn) { "html is still not supported" }
|
35
|
+
exit(1)
|
36
|
+
# create_file(data, file: file, format: :html)
|
37
|
+
when "json"
|
38
|
+
log(:warn) { "json is still not supported" }
|
39
|
+
exit(1)
|
40
|
+
# create_file(data, file: file, format: :json)
|
43
41
|
end
|
44
42
|
end
|
45
43
|
|
@@ -64,8 +62,8 @@ class Eco::API::UseCases::Default::People::SupersCyclicIdentify < Eco::API::Comm
|
|
64
62
|
|
65
63
|
"".tap do |str|
|
66
64
|
entry = set.shift
|
67
|
-
str << "
|
68
|
-
str << lev
|
65
|
+
str << " " * lev
|
66
|
+
str << lev&.positive? ? "+-#{lev}- " : ""
|
69
67
|
str << entry.name
|
70
68
|
str << " (#{entry.external_id}|#{entry.email}|#{entry.id})\n"
|
71
69
|
next unless set && !set.empty?
|