eco-helpers 3.0.4 → 3.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +2 -0
- data/CHANGELOG.md +44 -4
- data/eco-helpers.gemspec +1 -1
- data/lib/eco/api/common/class_helpers.rb +24 -23
- data/lib/eco/api/common/class_meta_basics.rb +0 -2
- data/lib/eco/api/common/loaders/use_case.rb +1 -0
- data/lib/eco/api/common/people/entry_factory.rb +6 -4
- data/lib/eco/api/common/people/person_entry.rb +4 -6
- data/lib/eco/api/common/people/person_entry_attribute_mapper.rb +25 -12
- data/lib/eco/api/common/people/person_parser.rb +8 -0
- data/lib/eco/api/common/session/base_session.rb +1 -1
- data/lib/eco/api/common/session/environment.rb +7 -0
- data/lib/eco/api/common/session/file_manager.rb +15 -8
- data/lib/eco/api/common/session/logger/cache.rb +14 -10
- data/lib/eco/api/common/session/logger/log.rb +8 -7
- data/lib/eco/api/common/session/mailer.rb +22 -13
- data/lib/eco/api/common/session/s3_uploader.rb +29 -20
- data/lib/eco/api/microcases/people_search.rb +1 -1
- data/lib/eco/api/organization/login_providers.rb +11 -4
- data/lib/eco/api/organization/node_classifications.rb +3 -0
- data/lib/eco/api/organization/presets_factory.rb +37 -31
- data/lib/eco/api/organization/tag_tree.rb +14 -5
- data/lib/eco/api/policies/default_policies/99_user_access_policy.rb +28 -18
- data/lib/eco/api/session/batch/errors.rb +38 -20
- data/lib/eco/api/session/batch/job.rb +252 -135
- data/lib/eco/api/session/batch/status.rb +55 -36
- data/lib/eco/api/session/batch.rb +2 -2
- data/lib/eco/api/session/config/base_config.rb +12 -11
- data/lib/eco/api/session/config/tagtree.rb +10 -14
- data/lib/eco/api/session/config/workflow.rb +15 -3
- data/lib/eco/api/session/config.rb +19 -26
- data/lib/eco/api/session.rb +13 -4
- data/lib/eco/api/usecases/cli.rb +4 -0
- data/lib/eco/api/usecases/default/locations/cli/codes_to_tags_cli.rb +18 -0
- data/lib/eco/api/usecases/default/locations/cli/csv_to_tree_cli.rb +12 -0
- data/lib/eco/api/usecases/default/locations/cli/tagtree_paths_cli.rb +12 -0
- data/lib/eco/api/usecases/default/locations/codes_to_tags_case.rb +32 -13
- data/lib/eco/api/usecases/default/locations/csv_to_tree_case.rb +15 -5
- data/lib/eco/api/usecases/default/locations/tagtree_extract_case.rb +6 -0
- data/lib/eco/api/usecases/default/locations/tagtree_paths_case.rb +51 -0
- data/lib/eco/api/usecases/default/locations.rb +1 -1
- data/lib/eco/api/usecases/default/people/amend/cli/reinvite_sync_cli.rb +8 -0
- data/lib/eco/api/usecases/default/people/amend/cli/reinvite_trans_cli.rb +11 -0
- data/lib/eco/api/usecases/default/people/amend/cli/restore_db_cli.rb +26 -0
- data/lib/eco/api/usecases/default/people/amend/reinvite_sync_case.rb +2 -0
- data/lib/eco/api/usecases/default/people/amend/reinvite_trans_case.rb +2 -0
- data/lib/eco/api/usecases/default/people/amend/restore_db_case.rb +3 -0
- data/lib/eco/api/usecases/default/people/treat/analyse_people_case.rb +15 -5
- data/lib/eco/api/usecases/default/people/treat/cli/analyse_people_cli.rb +66 -0
- data/lib/eco/api/usecases/default/people/treat/cli/org_data_convert_cli.rb +35 -0
- data/lib/eco/api/usecases/default/people/treat/cli/supers_cyclic_identify_cli.rb +15 -0
- data/lib/eco/api/usecases/default/people/treat/cli/supers_hierachy_cli.rb +15 -0
- data/lib/eco/api/usecases/default/people/treat/org_data_convert_case.rb +11 -5
- data/lib/eco/api/usecases/default/people/treat/supers_cyclic_identify_case.rb +28 -7
- data/lib/eco/api/usecases/default/people/treat/supers_hierarchy_case.rb +32 -9
- data/lib/eco/api/usecases/default/people/utils/set_default_tag_case.rb +2 -1
- data/lib/eco/api/usecases/default_cases/to_csv_case.rb +2 -2
- data/lib/eco/api/usecases/graphql/helpers/location/base/classifications_parser.rb +5 -0
- data/lib/eco/api/usecases/graphql/helpers/location/command/diffs/stages/commandable.rb +2 -0
- data/lib/eco/api/usecases/graphql/helpers/location/command/diffs/stages/diff_sortable.rb +2 -0
- data/lib/eco/api/usecases/graphql/helpers/location/command/result.rb +2 -1
- data/lib/eco/api/usecases/graphql/helpers/location/command/results.rb +3 -0
- data/lib/eco/api/usecases/graphql/helpers/location/command.rb +1 -0
- data/lib/eco/api/usecases/graphql/helpers/location/tags_remap.rb +3 -0
- data/lib/eco/api/usecases/graphql/samples/location/command/service/tree_update.rb +2 -0
- data/lib/eco/api/usecases/graphql/samples/location/command/track_changed_ids.rb +1 -0
- data/lib/eco/api/usecases/graphql/samples/location/service/tree_diff/convertible/parsing/classifications.rb +2 -0
- data/lib/eco/api/usecases/graphql/samples/location/service/tree_diff.rb +6 -2
- data/lib/eco/api/usecases/graphql/samples/location/service/tree_to_list/converter/parser.rb +6 -2
- data/lib/eco/api/usecases/graphql/samples/location/service/tree_to_list/converter.rb +2 -0
- data/lib/eco/api/usecases/ooze_cases/export_register_case.rb +1 -0
- data/lib/eco/api/usecases/ooze_samples/helpers_migration/copying.rb +66 -29
- data/lib/eco/api/usecases/ooze_samples/ooze_base_case.rb +25 -3
- data/lib/eco/api/usecases/ooze_samples/register_update_case.rb +10 -0
- data/lib/eco/api/usecases/use_case.rb +3 -1
- data/lib/eco/cli/config/use_cases.rb +4 -0
- data/lib/eco/cli/scripting/args_helpers.rb +3 -2
- data/lib/eco/cli/scripting/argument.rb +2 -2
- data/lib/eco/cli_default/input.rb +49 -45
- data/lib/eco/cli_default/input_filters.rb +32 -17
- data/lib/eco/cli_default/options.rb +8 -4
- data/lib/eco/cli_default/people.rb +1 -1
- data/lib/eco/cli_default/people_filters.rb +32 -24
- data/lib/eco/cli_default/usecases.rb +8 -121
- data/lib/eco/cli_default/workflow.rb +6 -4
- data/lib/eco/csv/split.rb +2 -0
- data/lib/eco/csv/table.rb +13 -0
- data/lib/eco/data/files/encoding.rb +15 -8
- data/lib/eco/data/files/helpers.rb +6 -2
- data/lib/eco/data/hashes/diff_result.rb +5 -0
- data/lib/eco/data/locations/node_diff/nodes_diff.rb +13 -0
- data/lib/eco/data/locations/node_diff.rb +4 -0
- data/lib/eco/data/locations/node_level.rb +6 -0
- data/lib/eco/language/auxiliar_logger.rb +2 -0
- data/lib/eco/version.rb +1 -1
- data/lib/eco-helpers.rb +1 -1
- metadata +15 -6
- data/lib/eco/api/usecases/default/locations/create_tag_paths_case.rb +0 -25
- data/lib/eco/api/usecases/default/people/amend/reinvite_trans_cli.rb +0 -4
@@ -4,6 +4,8 @@ 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
|
+
include Eco::Language::AuxiliarLogger
|
8
|
+
|
7
9
|
# @attr_reader status [Eco::API::Session::Batch::Status] `batch status` this `Errors` object is associated to.
|
8
10
|
attr_reader :status
|
9
11
|
|
@@ -41,7 +43,7 @@ module Eco
|
|
41
43
|
end
|
42
44
|
|
43
45
|
def logger
|
44
|
-
status.logger
|
46
|
+
status.logger || super
|
45
47
|
end
|
46
48
|
# @!endgroup
|
47
49
|
|
@@ -84,6 +86,7 @@ module Eco
|
|
84
86
|
next unless (body = response.body)
|
85
87
|
|
86
88
|
errs = []
|
89
|
+
|
87
90
|
case body
|
88
91
|
when Hash
|
89
92
|
body_errs = body["errors"] || body["error"]
|
@@ -111,6 +114,7 @@ module Eco
|
|
111
114
|
|
112
115
|
def message
|
113
116
|
msgs = strs
|
117
|
+
|
114
118
|
if msgs.empty?
|
115
119
|
"There were no errors for the current batch '#{method}'!! ;)"
|
116
120
|
else
|
@@ -120,10 +124,15 @@ module Eco
|
|
120
124
|
|
121
125
|
def print
|
122
126
|
msgs = strs
|
127
|
+
|
123
128
|
if msgs.empty?
|
124
|
-
|
129
|
+
log(:info) {
|
130
|
+
"There were no errors for the current batch '#{method}'!! ;)"
|
131
|
+
}
|
125
132
|
else
|
126
|
-
|
133
|
+
msg = "There were #{msgs.length} errors:\n"
|
134
|
+
msg << msgs.join("\n")
|
135
|
+
log(:error) { msg }
|
127
136
|
end
|
128
137
|
end
|
129
138
|
# @!endgroup
|
@@ -140,20 +149,29 @@ module Eco
|
|
140
149
|
# - please, observe that this can only happen if there were repeated entries in the `source_queue`
|
141
150
|
# @return [Array<Hash>, Array<Ecoportal::API::V1::Person>, Array<Ecoportal::API::Internal::Person>]
|
142
151
|
def entries
|
143
|
-
queue.
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
+
queue.reject.with_index do |query, i|
|
153
|
+
response = status[i]
|
154
|
+
|
155
|
+
next response.success? if response
|
156
|
+
|
157
|
+
msg = "Error: query with no response. You might have duplicated entries in your queue.\n"
|
158
|
+
msg << "Queue length: #{queue.length}; Queue elements class: #{queue.first.class}\n"
|
159
|
+
msg << "Query with no response. Person: #{person_ref(query)}\n"
|
160
|
+
|
161
|
+
queue.map do |entry|
|
162
|
+
identifiable = %i[id external_id email].any? do |attr|
|
163
|
+
next false unless (val = get_attr(entry, attr))
|
164
|
+
|
165
|
+
val == get_attr(query, attr)
|
152
166
|
end
|
153
|
-
|
167
|
+
|
168
|
+
next unless identifiable
|
169
|
+
|
170
|
+
msg << "It could be this peson entry (idx: #{to_index(entry)}): "
|
171
|
+
msg << "#{person_ref(entry)}\n"
|
154
172
|
end
|
155
173
|
|
156
|
-
|
174
|
+
raise msg
|
157
175
|
end
|
158
176
|
end
|
159
177
|
|
@@ -177,21 +195,21 @@ module Eco
|
|
177
195
|
# @param key [Integer, Ecoportal::API::V1::Person]
|
178
196
|
# @return [String] the error description.
|
179
197
|
def str(key)
|
180
|
-
|
181
|
-
|
198
|
+
"".tap do |msg|
|
199
|
+
next if status.success?(key)
|
200
|
+
|
182
201
|
i = to_index(key)
|
183
202
|
entry = queue.to_a[i]
|
184
203
|
response = status[i]
|
185
|
-
msg
|
186
|
-
msg
|
204
|
+
msg << "Error #{response.status}: #{response.body}\n"
|
205
|
+
msg << "-- Failed to #{method}. Person: #{person_ref(entry)}"
|
187
206
|
end
|
188
|
-
msg
|
189
207
|
end
|
190
208
|
|
191
209
|
def print_one(key)
|
192
210
|
return if status.success?(key)
|
193
211
|
|
194
|
-
|
212
|
+
log(:error) { str(key) }
|
195
213
|
end
|
196
214
|
end
|
197
215
|
end
|