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.
Files changed (100) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +2 -0
  3. data/CHANGELOG.md +44 -4
  4. data/eco-helpers.gemspec +1 -1
  5. data/lib/eco/api/common/class_helpers.rb +24 -23
  6. data/lib/eco/api/common/class_meta_basics.rb +0 -2
  7. data/lib/eco/api/common/loaders/use_case.rb +1 -0
  8. data/lib/eco/api/common/people/entry_factory.rb +6 -4
  9. data/lib/eco/api/common/people/person_entry.rb +4 -6
  10. data/lib/eco/api/common/people/person_entry_attribute_mapper.rb +25 -12
  11. data/lib/eco/api/common/people/person_parser.rb +8 -0
  12. data/lib/eco/api/common/session/base_session.rb +1 -1
  13. data/lib/eco/api/common/session/environment.rb +7 -0
  14. data/lib/eco/api/common/session/file_manager.rb +15 -8
  15. data/lib/eco/api/common/session/logger/cache.rb +14 -10
  16. data/lib/eco/api/common/session/logger/log.rb +8 -7
  17. data/lib/eco/api/common/session/mailer.rb +22 -13
  18. data/lib/eco/api/common/session/s3_uploader.rb +29 -20
  19. data/lib/eco/api/microcases/people_search.rb +1 -1
  20. data/lib/eco/api/organization/login_providers.rb +11 -4
  21. data/lib/eco/api/organization/node_classifications.rb +3 -0
  22. data/lib/eco/api/organization/presets_factory.rb +37 -31
  23. data/lib/eco/api/organization/tag_tree.rb +14 -5
  24. data/lib/eco/api/policies/default_policies/99_user_access_policy.rb +28 -18
  25. data/lib/eco/api/session/batch/errors.rb +38 -20
  26. data/lib/eco/api/session/batch/job.rb +252 -135
  27. data/lib/eco/api/session/batch/status.rb +55 -36
  28. data/lib/eco/api/session/batch.rb +2 -2
  29. data/lib/eco/api/session/config/base_config.rb +12 -11
  30. data/lib/eco/api/session/config/tagtree.rb +10 -14
  31. data/lib/eco/api/session/config/workflow.rb +15 -3
  32. data/lib/eco/api/session/config.rb +19 -26
  33. data/lib/eco/api/session.rb +13 -4
  34. data/lib/eco/api/usecases/cli.rb +4 -0
  35. data/lib/eco/api/usecases/default/locations/cli/codes_to_tags_cli.rb +18 -0
  36. data/lib/eco/api/usecases/default/locations/cli/csv_to_tree_cli.rb +12 -0
  37. data/lib/eco/api/usecases/default/locations/cli/tagtree_paths_cli.rb +12 -0
  38. data/lib/eco/api/usecases/default/locations/codes_to_tags_case.rb +32 -13
  39. data/lib/eco/api/usecases/default/locations/csv_to_tree_case.rb +15 -5
  40. data/lib/eco/api/usecases/default/locations/tagtree_extract_case.rb +6 -0
  41. data/lib/eco/api/usecases/default/locations/tagtree_paths_case.rb +51 -0
  42. data/lib/eco/api/usecases/default/locations.rb +1 -1
  43. data/lib/eco/api/usecases/default/people/amend/cli/reinvite_sync_cli.rb +8 -0
  44. data/lib/eco/api/usecases/default/people/amend/cli/reinvite_trans_cli.rb +11 -0
  45. data/lib/eco/api/usecases/default/people/amend/cli/restore_db_cli.rb +26 -0
  46. data/lib/eco/api/usecases/default/people/amend/reinvite_sync_case.rb +2 -0
  47. data/lib/eco/api/usecases/default/people/amend/reinvite_trans_case.rb +2 -0
  48. data/lib/eco/api/usecases/default/people/amend/restore_db_case.rb +3 -0
  49. data/lib/eco/api/usecases/default/people/treat/analyse_people_case.rb +15 -5
  50. data/lib/eco/api/usecases/default/people/treat/cli/analyse_people_cli.rb +66 -0
  51. data/lib/eco/api/usecases/default/people/treat/cli/org_data_convert_cli.rb +35 -0
  52. data/lib/eco/api/usecases/default/people/treat/cli/supers_cyclic_identify_cli.rb +15 -0
  53. data/lib/eco/api/usecases/default/people/treat/cli/supers_hierachy_cli.rb +15 -0
  54. data/lib/eco/api/usecases/default/people/treat/org_data_convert_case.rb +11 -5
  55. data/lib/eco/api/usecases/default/people/treat/supers_cyclic_identify_case.rb +28 -7
  56. data/lib/eco/api/usecases/default/people/treat/supers_hierarchy_case.rb +32 -9
  57. data/lib/eco/api/usecases/default/people/utils/set_default_tag_case.rb +2 -1
  58. data/lib/eco/api/usecases/default_cases/to_csv_case.rb +2 -2
  59. data/lib/eco/api/usecases/graphql/helpers/location/base/classifications_parser.rb +5 -0
  60. data/lib/eco/api/usecases/graphql/helpers/location/command/diffs/stages/commandable.rb +2 -0
  61. data/lib/eco/api/usecases/graphql/helpers/location/command/diffs/stages/diff_sortable.rb +2 -0
  62. data/lib/eco/api/usecases/graphql/helpers/location/command/result.rb +2 -1
  63. data/lib/eco/api/usecases/graphql/helpers/location/command/results.rb +3 -0
  64. data/lib/eco/api/usecases/graphql/helpers/location/command.rb +1 -0
  65. data/lib/eco/api/usecases/graphql/helpers/location/tags_remap.rb +3 -0
  66. data/lib/eco/api/usecases/graphql/samples/location/command/service/tree_update.rb +2 -0
  67. data/lib/eco/api/usecases/graphql/samples/location/command/track_changed_ids.rb +1 -0
  68. data/lib/eco/api/usecases/graphql/samples/location/service/tree_diff/convertible/parsing/classifications.rb +2 -0
  69. data/lib/eco/api/usecases/graphql/samples/location/service/tree_diff.rb +6 -2
  70. data/lib/eco/api/usecases/graphql/samples/location/service/tree_to_list/converter/parser.rb +6 -2
  71. data/lib/eco/api/usecases/graphql/samples/location/service/tree_to_list/converter.rb +2 -0
  72. data/lib/eco/api/usecases/ooze_cases/export_register_case.rb +1 -0
  73. data/lib/eco/api/usecases/ooze_samples/helpers_migration/copying.rb +66 -29
  74. data/lib/eco/api/usecases/ooze_samples/ooze_base_case.rb +25 -3
  75. data/lib/eco/api/usecases/ooze_samples/register_update_case.rb +10 -0
  76. data/lib/eco/api/usecases/use_case.rb +3 -1
  77. data/lib/eco/cli/config/use_cases.rb +4 -0
  78. data/lib/eco/cli/scripting/args_helpers.rb +3 -2
  79. data/lib/eco/cli/scripting/argument.rb +2 -2
  80. data/lib/eco/cli_default/input.rb +49 -45
  81. data/lib/eco/cli_default/input_filters.rb +32 -17
  82. data/lib/eco/cli_default/options.rb +8 -4
  83. data/lib/eco/cli_default/people.rb +1 -1
  84. data/lib/eco/cli_default/people_filters.rb +32 -24
  85. data/lib/eco/cli_default/usecases.rb +8 -121
  86. data/lib/eco/cli_default/workflow.rb +6 -4
  87. data/lib/eco/csv/split.rb +2 -0
  88. data/lib/eco/csv/table.rb +13 -0
  89. data/lib/eco/data/files/encoding.rb +15 -8
  90. data/lib/eco/data/files/helpers.rb +6 -2
  91. data/lib/eco/data/hashes/diff_result.rb +5 -0
  92. data/lib/eco/data/locations/node_diff/nodes_diff.rb +13 -0
  93. data/lib/eco/data/locations/node_diff.rb +4 -0
  94. data/lib/eco/data/locations/node_level.rb +6 -0
  95. data/lib/eco/language/auxiliar_logger.rb +2 -0
  96. data/lib/eco/version.rb +1 -1
  97. data/lib/eco-helpers.rb +1 -1
  98. metadata +15 -6
  99. data/lib/eco/api/usecases/default/locations/create_tag_paths_case.rb +0 -25
  100. 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
- logger.info("There were no errors for the current batch '#{method}'!! ;)")
129
+ log(:info) {
130
+ "There were no errors for the current batch '#{method}'!! ;)"
131
+ }
125
132
  else
126
- logger.error("There were #{msgs.length} errors:\n" + msgs.join("\n"))
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.select.with_index do |query, i|
144
- unless (response = status[i])
145
- msg = "Error: query with no response. You might have duplicated entries in your queue.\n"
146
- msg += "Queue length: #{queue.length}; Queue elements class: #{queue.first.class}\n"
147
- msg += "Query with no response. Person: #{person_ref(query)}\n"
148
- queue.map do |entry|
149
- if %i[id external_id email].any? {|attr| (v = get_attr(entry, attr)) && v == get_attr(query, attr)}
150
- msg += "It could be this peson entry (idx: #{to_index(entry)}): #{person_ref(entry)}\n"
151
- end
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
- raise msg
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
- !response.success?
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
- msg = ""
181
- unless status.success?(key)
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 = "Error #{response.status}: #{response.body}\n"
186
- msg += "-- Failed to #{method}. Person: #{person_ref(entry)}"
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
- logger.error(str(key))
212
+ log(:error) { str(key) }
195
213
  end
196
214
  end
197
215
  end