eco-helpers 2.6.0 → 2.6.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +91 -1
  3. data/README.md +5 -0
  4. data/eco-helpers.gemspec +1 -1
  5. data/lib/eco/api/common/class_helpers.rb +1 -1
  6. data/lib/eco/api/common/loaders/base.rb +5 -0
  7. data/lib/eco/api/common/loaders/case_base.rb +0 -2
  8. data/lib/eco/api/common/loaders/config/workflow/mailer.rb +78 -0
  9. data/lib/eco/api/common/loaders/config/workflow.rb +11 -0
  10. data/lib/eco/api/common/loaders/config.rb +29 -0
  11. data/lib/eco/api/common/loaders/error_handler.rb +0 -2
  12. data/lib/eco/api/common/loaders/parser.rb +0 -1
  13. data/lib/eco/api/common/loaders/policy.rb +0 -2
  14. data/lib/eco/api/common/loaders.rb +1 -0
  15. data/lib/eco/api/common/session/mailer.rb +3 -1
  16. data/lib/eco/api/common/version_patches/exception.rb +2 -2
  17. data/lib/eco/api/common/version_patches/ruby3/object.rb +18 -0
  18. data/lib/eco/api/common/version_patches/ruby3.rb +1 -0
  19. data/lib/eco/api/common/version_patches.rb +3 -0
  20. data/lib/eco/api/custom/config.rb +10 -0
  21. data/lib/eco/api/custom/mailer.rb +9 -0
  22. data/lib/eco/api/custom/namespace.rb +2 -0
  23. data/lib/eco/api/custom/workflow.rb +9 -0
  24. data/lib/eco/api/custom.rb +3 -0
  25. data/lib/eco/api/session/batch/base_policy.rb +13 -5
  26. data/lib/eco/api/session/batch/job.rb +10 -7
  27. data/lib/eco/api/session/config/tagtree.rb +15 -1
  28. data/lib/eco/api/session/config/workflow.rb +94 -58
  29. data/lib/eco/api/session/config.rb +2 -2
  30. data/lib/eco/api/usecases/base_io.rb +50 -4
  31. data/lib/eco/api/usecases/cli/dsl.rb +23 -13
  32. data/lib/eco/api/usecases/default/locations/cli/tagtree_extract_cli.rb +5 -0
  33. data/lib/eco/api/usecases/default/locations/tagtree_extract_case.rb +12 -4
  34. data/lib/eco/api/usecases/graphql/helpers/location/base.rb +1 -2
  35. data/lib/eco/api/usecases/ooze_samples/helpers/creatable.rb +62 -0
  36. data/lib/eco/api/usecases/ooze_samples/helpers/rescuable.rb +59 -0
  37. data/lib/eco/api/usecases/ooze_samples/helpers.rb +2 -0
  38. data/lib/eco/api/usecases/ooze_samples/ooze_base_case.rb +2 -1
  39. data/lib/eco/api/usecases/ooze_samples/register_migration_case.rb +2 -26
  40. data/lib/eco/api/usecases/ooze_samples/register_update_case.rb +64 -47
  41. data/lib/eco/api/usecases/ooze_samples/target_oozes_update_case.rb +8 -0
  42. data/lib/eco/api/usecases/use_case.rb +12 -2
  43. data/lib/eco/assets.rb +2 -2
  44. data/lib/eco/cli_default/workflow.rb +102 -120
  45. data/lib/eco/data/locations/node_base/tag_validations.rb +19 -9
  46. data/lib/eco/data/locations/node_base/treeify.rb +193 -18
  47. data/lib/eco/data/locations/node_diff/nodes_diff.rb +11 -9
  48. data/lib/eco/data/locations/node_diff/selectors.rb +1 -1
  49. data/lib/eco/data/locations/node_level.rb +1 -1
  50. data/lib/eco/data/locations/node_plain/parsing.rb +1 -1
  51. data/lib/eco/data/locations/node_plain/serial.rb +1 -1
  52. data/lib/eco/data/locations/node_plain.rb +4 -3
  53. data/lib/eco/language/klass/when_inherited.rb +17 -0
  54. data/lib/eco/language/klass.rb +8 -0
  55. data/lib/eco/language/methods/delegate_missing.rb +28 -0
  56. data/lib/eco/language/methods/dsl_able.rb +25 -0
  57. data/lib/eco/language/methods.rb +9 -0
  58. data/lib/eco/language.rb +2 -0
  59. data/lib/eco/version.rb +1 -1
  60. metadata +18 -3
@@ -66,8 +66,8 @@ class Eco::API::UseCases::OozeSamples::RegisterMigrationCase < Eco::API::UseCase
66
66
 
67
67
  def process_ooze
68
68
  with_target_stage(self.class::SOURCE_STAGE) do |source|
69
- drafting_entry(self.class::TEMPLATE_ID) do |draft|
70
- draft_reference = object_reference(source)
69
+ draft_reference = object_reference(source)
70
+ creating_new_page(draft_reference, template_id: elf.class::TEMPLATE_ID) do |draft|
71
71
  draft.base_tags << ["IMPORTED", "MIGRATED"]
72
72
 
73
73
  pairing_tracking = copy_pairings(source, draft)
@@ -89,13 +89,6 @@ class Eco::API::UseCases::OozeSamples::RegisterMigrationCase < Eco::API::UseCase
89
89
  if msg = pairing_tracking.report_dst_unpaired(only_required: false, exclude_ximport: !self.class::REPORT_DST_XIMPORT)
90
90
  logger.warn(msg)
91
91
  end
92
-
93
- if page_id = create_entry(draft, reference: draft_reference)
94
- csv << [source.id, page_id]
95
- logger.info("Page '#{page_id}' created successfully.")
96
- elsif options.dig(:dry_run)
97
- logger.info("Simulated launch for #{draft_reference}")
98
- end
99
92
  end
100
93
  end
101
94
  end
@@ -153,23 +146,6 @@ class Eco::API::UseCases::OozeSamples::RegisterMigrationCase < Eco::API::UseCase
153
146
  "#{sym}_callback".to_sym
154
147
  end
155
148
 
156
- def create_entry(draft, reference:, from: self.class::TEMPLATE_ID)
157
- with_rescue(reference) do
158
- if !options[:dry_run]
159
- create_ooze(draft, template_id: from).page_id
160
- else
161
- logger.info("Creation sample follows...")
162
- dry_run_feedback(draft)
163
- false
164
- end
165
- end
166
- end
167
-
168
- def drafting_entry(template_id = selfTEMPLATE_ID)
169
- draft = apiv2.pages.get_new(template_id)
170
- yield(draft)
171
- end
172
-
173
149
  def with_target_stage(name)
174
150
  if stg = target_stage(name)
175
151
  yield(stg)
@@ -4,6 +4,8 @@
4
4
  # - You need to define the `process_ooze` method
5
5
  # This case expects `options[:source][:register_id]`
6
6
  class Eco::API::UseCases::OozeSamples::RegisterUpdateCase < Eco::API::UseCases::OozeSamples::OozeBaseCase
7
+ include Eco::API::UseCases::OozeSamples::Helpers::Creatable
8
+
7
9
  class << self
8
10
  # @return [Integer] the number of pages to be processed in each batch
9
11
  def batch_size(size = nil)
@@ -18,31 +20,25 @@ class Eco::API::UseCases::OozeSamples::RegisterUpdateCase < Eco::API::UseCases::
18
20
 
19
21
  attr_reader :retrieved_oozes, :non_retrieved_oozes
20
22
  attr_reader :total_search_oozes, :dupped_search_oozes
21
- attr_reader :ooze_result_ids, :updated_oozes, :failed_update_oozes, :created_oozes
23
+ attr_reader :ooze_result_ids
24
+ attr_reader :updated_oozes, :failed_update_oozes, :attempted_ooze_updates
25
+ attr_reader :created_oozes, :ooze_create_attempts
22
26
 
23
- def main(session, options, usecase, &block)
24
- @retrieved_oozes = 0
25
- @non_retrieved_oozes = 0
26
- @dupped_search_oozes = 0
27
- @ooze_result_ids = {}
28
- @updated_oozes = 0
29
- @failed_update_oozes = 0
30
- @created_oozes = 0
27
+ def main(session, options, usecase, mode: :legacy, &block)
28
+ init_kpis
31
29
 
32
30
  super(session, options, usecase) do
33
- with_each_entry do |ooze|
34
- process_ooze(&block)
31
+ if mode == :legacy
32
+ with_each_entry do |ooze|
33
+ process_ooze(&block)
34
+ end
35
+ elsif mode == :delegate
36
+ raise "You need to pass a block when running main in `:delegate` mode" unless block_given?
37
+ yield
35
38
  end
36
39
  end
37
- msg = "Run end:\n"
38
- msg += " • Search results: #{total_search_oozes}\n"
39
- msg += " • Duplicated search results #{dupped_search_oozes}\n"
40
- msg += " • Retrieved a total of #{retrieved_oozes}\n"
41
- msg += " • Could not get #{non_retrieved_oozes} oozes.\n"
42
- msg += " • Updated #{updated_oozes} oozes.\n"
43
- msg += " - Failed update on #{failed_update_oozes} oozes.\n"
44
- msg += " • Created #{created_oozes} oozes.\n"
45
- logger.info(msg)
40
+
41
+ log_kpis
46
42
  end
47
43
 
48
44
  def process_ooze(ooze = target)
@@ -51,29 +47,6 @@ class Eco::API::UseCases::OozeSamples::RegisterUpdateCase < Eco::API::UseCases::
51
47
 
52
48
  private
53
49
 
54
- def with_rescue(reference)
55
- begin
56
- yield
57
- rescue StandardError => e
58
- logger.error([reference, e.message].join(' => \n'))
59
- lines = []
60
- lines << '\nThere was an error. Choose one option:\n'
61
- lines << ' (C) - Continue/resume. Just ignore this one.'
62
- lines << ' (A) - Abort. Just break this run.'
63
-
64
- session.prompt_user('Type one option (C/a):', explanation: lines.join('\n'), default: 'C') do |res|
65
- res = res.upcase
66
- case
67
- when res.start_with?("A")
68
- raise
69
- else res.start_with?("C")
70
- logger.warn "Script resumed after error..."
71
- nil
72
- end
73
- end
74
- end
75
- end
76
-
77
50
  def before_loading_new_target(ooze_id)
78
51
  if pending = queue_shift(ooze_id)
79
52
  update_ooze(pending).tap do |result|
@@ -95,6 +68,7 @@ class Eco::API::UseCases::OozeSamples::RegisterUpdateCase < Eco::API::UseCases::
95
68
  end
96
69
  end
97
70
 
71
+ # Main looper (invoked from `main`)
98
72
  def with_each_entry
99
73
  batched_search_results do |page_results|
100
74
  page_results.each do |page_result|
@@ -172,12 +146,26 @@ class Eco::API::UseCases::OozeSamples::RegisterUpdateCase < Eco::API::UseCases::
172
146
  yield(results) unless results.empty?
173
147
  end
174
148
 
149
+ # Launches the actual request to create the entry
175
150
  def create_ooze(draft, template_id:)
176
- apiv2.pages.create(draft, from: template_id).tap do |result|
177
- @created_oozes += 1
151
+ @ooze_create_attempts += 1
152
+
153
+ if dry_run?
154
+ dry_run_feedback(ooze)
155
+ false
156
+ else
157
+ apiv2.pages.create(draft, from: template_id).tap do |result|
158
+ @created_oozes += 1
159
+ end
178
160
  end
179
161
  end
180
162
 
163
+ # Capture the attempts count
164
+ def update_ooze(*args, **kargs, &block)
165
+ @attempted_ooze_updates += 1 if dirty?(ooze)
166
+ super
167
+ end
168
+
181
169
  def update_oozes(batched_oozes = batch_queue)
182
170
  batched_oozes.each do |ooze|
183
171
  update_ooze(ooze).tap do |result|
@@ -215,10 +203,39 @@ class Eco::API::UseCases::OozeSamples::RegisterUpdateCase < Eco::API::UseCases::
215
203
  end
216
204
  end
217
205
 
206
+ def init_kpis
207
+ @retrieved_oozes = 0
208
+ @non_retrieved_oozes = 0
209
+ @dupped_search_oozes = 0
210
+ @ooze_result_ids = {}
211
+ @updated_oozes = 0
212
+ @failed_update_oozes = 0
213
+ @attempted_ooze_updates = 0
214
+ @created_oozes = 0
215
+ @ooze_create_attempts = 0
216
+ end
217
+
218
+ def log_kpis
219
+ log(:info) { kpis_message }
220
+ end
221
+
222
+ def kpis_message
223
+ msg = []
224
+ msg << "Run end:"
225
+ msg << " • Search results: #{total_search_oozes}"
226
+ msg << " • Duplicated search results #{dupped_search_oozes}"
227
+ msg << " • Retrieved a total of #{retrieved_oozes}"
228
+ msg << " • Could not get #{non_retrieved_oozes} oozes."
229
+ msg << " • Updated #{updated_oozes} oozes (attempted: #{attempted_ooze_updates})."
230
+ msg << " - Failed update on #{failed_update_oozes} oozes."
231
+ msg << " • Created #{created_oozes} oozes (out of: #{ooze_create_attempts})."
232
+ msg.join("\n")
233
+ end
234
+
218
235
  def search_options
219
236
  @search_options ||= {}.tap do |opts|
220
- opts.merge!(sort: "created_at")
221
- opts.merge!(dir: "asc")
237
+ opts.merge!(sort: 'created_at')
238
+ opts.merge!(dir: 'asc')
222
239
  opts.merge!(query: conf_search) if conf_search
223
240
  opts.merge!(filters: conf_filters)
224
241
  end
@@ -19,7 +19,11 @@ class Eco::API::UseCases::OozeSamples::TargetOozesUpdateCase < Eco::API::UseCase
19
19
  end
20
20
  end
21
21
  if ooz = ooze(id)
22
+ @retrieved_oozes += 1
22
23
  yield(ooz)
24
+ else
25
+ @non_retrieved_oozes += 1
26
+ logger.warn "Could not get page #{id}"
23
27
  end
24
28
  end
25
29
  update_oozes
@@ -42,8 +46,12 @@ class Eco::API::UseCases::OozeSamples::TargetOozesUpdateCase < Eco::API::UseCase
42
46
 
43
47
  def target_ids_preview
44
48
  dups = target_ids.select {|id| target_ids.count(id) > 1}
49
+ @total_search_oozes = target_ids.count
50
+ @dupped_search_oozes = dups.count
51
+
45
52
  dups_str = dups.count > 0 ? "There are #{dups.count} duplicated ids" : "No duplicates detected"
46
53
  msg = "Total target entries: #{target_ids.count} (#{dups_str})"
54
+
47
55
  session.prompt_user("Do you want to proceed (y/N):", explanation: msg, default: "N", timeout: 10) do |res|
48
56
  unless res.upcase.start_with?("Y")
49
57
  puts "..."
@@ -40,6 +40,7 @@ module Eco
40
40
  # @option kargs [Eco::API::Organization::People] :people object.
41
41
  # @option kargs [Eco::API:Session] :session
42
42
  # @option kargs [Hash] :options hash with symbol keys (i.e. behaviour modifiers, cli trackers, filters, etc.)
43
+ # @return [Eco::API::UseCases::UseCaseIO] an io with the result in output
43
44
  def launch(io: nil, **kargs)
44
45
  params = io&.params(keyed: true, all: true) || {}
45
46
  kargs = params.merge(kargs).merge(usecase: self)
@@ -88,12 +89,21 @@ module Eco
88
89
  callback_self.instance_eval do
89
90
  @session = sess
90
91
  @options = opts
91
- @people = peo if peo
92
- @input = ent if ent
92
+ if peo
93
+ @people = peo
94
+ self.singleton_class.attr_reader(:people) unless respond_to?(:people)
95
+ end
96
+
97
+ if ent # entries/input
98
+ @input = ent
99
+ self.singleton_class.attr_reader(:input) unless respond_to?(:input)
100
+ end
93
101
 
94
102
  # `self` is the use case itself (when used the Loader)
95
103
  next unless self.is_a?(Eco::API::Common::Loaders::CaseBase)
104
+
96
105
  @usecase = use_case_self
106
+ self.singleton_class.attr_reader(:usecase) unless respond_to?(:usecase)
97
107
  end
98
108
  true
99
109
  end
data/lib/eco/assets.rb CHANGED
@@ -31,12 +31,12 @@ module Eco
31
31
  @configs ||= {}
32
32
  end
33
33
 
34
- def cli
34
+ def cli(&block)
35
35
  unless @cli_init
36
36
  @cli_init = true
37
37
  require_relative('cli_default')
38
38
  end
39
- @cli
39
+ @cli.tap { yield(@cli) if block_given? }
40
40
  end
41
41
  end
42
42
  end
@@ -1,189 +1,171 @@
1
- ASSETS.cli.config do |config|
1
+ ASSETS.cli do |cli|
2
2
  ASSETS.config.workflow do |wf|
3
- io = nil
4
- rescued = false
5
- cases_with_input = nil
6
- cases_with_output = nil
7
3
 
4
+ rescued = false
8
5
  # default rescue
9
- wf.rescue do |exception, io|
10
- begin
11
- next io if rescued
12
- rescued = true
13
-
14
- io.session.logger.debug(exception.patch_full_message)
15
- wf.run(:close, io: io)
16
- rescue Exception => e
17
- puts "Some problem in workflow.rescue: #{e}"
18
- end
19
- io
6
+ wf.rescue do |err, io|
7
+ next io if rescued
8
+ rescued = true
9
+ log(:debug) { err.patch_full_message }
10
+ wf.run(:close, io: io)
11
+ rescue StandardError => e
12
+ puts "Some problem in workflow.rescue: #{e}"
20
13
  end
21
14
 
22
- wf.on(:options) do |wf_options, io|
23
- config.usecases.cli_apply(io: io)
24
- io = io.new(options: config.options_set.process(io: io))
15
+ wf.on(:options) do |_wf_opt, io|
16
+ cli.config.usecases.cli_apply(io: io)
17
+ io.new(options: cli.config.options_set.process(io: io))
25
18
  end
26
19
 
27
20
  wf.for(:load) do |wf_load|
28
- wf_load.for(:input) do |wf_input|
29
- wf_input.on(:get) do |wf_input_get, io|
30
- cases_with_input = config.usecases.active(io: io).select do |usecase, data|
21
+ wf_load.for(:input) do |wf_in|
22
+ wf_in.on(:get) do |_wf_ig, io|
23
+ cases_with_input = cli.config.usecases.active(io: io).select do |usecase, data|
31
24
  io.class.input_required?(usecase.type)
32
25
  end
33
26
 
34
- input_is_required = !cases_with_input.empty? || io.options.dig(:input, :entries_from)
35
- missing_input = !io.input || io.input.empty?
36
- next io unless missing_input && input_is_required
27
+ input_is_required = !cases_with_input.empty? || options.dig(:input, :entries_from)
28
+ missing_input = !input || input.empty?
29
+ next unless missing_input && input_is_required
37
30
 
38
- if io.options.dig(:input, :entries_from)
39
- io = io.new(input: config.input.get(io: io))
31
+ if options.dig(:input, :entries_from)
32
+ io.new(input: cli.config.input.get(io: io))
40
33
  else
41
34
  opt_case = cases_with_input.values.first.option
42
- io = io.new(input: config.input.get(io: io, option: opt_case))
35
+ io.new(input: cli.config.input.get(io: io, option: opt_case))
43
36
  end
44
- io
45
37
  end
46
38
 
47
- wf_input.on(:filter) do |wf_input_filter, io|
48
- next io unless io.input && !io.input.empty?
49
- io = io.new(input: config.input_filters.process(io: io))
39
+ wf_in.on(:filter) do |_wf_if, io|
40
+ next unless input && !input.empty?
41
+ io.new(input: cli.config.input_filters.process(io: io))
50
42
  end
51
43
  end
52
44
 
53
- wf_load.for(:people) do |wf_people|
54
- wf_people.on(:get) do |wf_people_get, io|
55
- cases_with_people = config.usecases.active(io: io).select do |usecase, data|
45
+ wf_load.for(:people) do |wf_peo|
46
+ wf_peo.on(:get) do |_wf_pg, io|
47
+ cases_with_people = cli.config.usecases.active(io: io).select do |usecase, data|
56
48
  io.class.people_required?(usecase.type)
57
49
  end
58
- next io if cases_with_people.empty? && !io.options.dig(:people, :get)
59
- io = io.new(people: config.people(io: io))
50
+ next if cases_with_people.empty? && !options.dig(:people, :get)
51
+ io.new(people: cli.config.people(io: io))
60
52
  end
61
53
 
62
- wf_people.on(:filter) do |wf_people_filter, io|
63
- next io unless io.people && !io.people.empty?
64
- io = io.new(people: config.people_filters.process(io: io))
54
+ wf_peo.on(:filter) do |_wf_pf, io|
55
+ next unless people && !people.empty?
56
+ io.new(people: cli.config.people_filters.process(io: io))
65
57
  end
66
58
  end
67
59
  end
68
60
 
69
- wf.before(:usecases) do |wf_cases, io|
61
+ wf.before(:usecases) do |_wf_ca, io|
70
62
  # save partial entries -> should be native to session.workflow
71
- get_people = io.options.dig(:people, :get)
63
+ get_people = options.dig(:people, :get)
72
64
  partial_update = get_people && get_people.dig(:type) == :partial
73
- if !io.options[:dry_run] && partial_update
74
- partial_file = io.session.config.people.partial_cache
75
- io.session.file_manager.save_json(io.people, partial_file, :timestamp)
65
+ if !options[:dry_run] && partial_update
66
+ partial_file = session.config.people.partial_cache
67
+ session.file_manager.save_json(io.people, partial_file, :timestamp)
76
68
  end
77
- io
78
69
  end
79
70
 
80
- wf.on(:usecases) do |wf_cases, io|
81
- unless config.usecases.process(io: io)
82
- msg = "No update operation specified... quitting"
83
- io.session.logger.info(msg)
84
- exit(0)
71
+ wf.on(:usecases) do |_wf_ca, io|
72
+ unless cli.config.usecases.process(io: io)
73
+ log(:info) { "No update operation specified... quitting" }
74
+ exit 0
85
75
  end
86
- io
87
76
  end
88
77
 
89
- wf.before(:launch_jobs) do |wf_jobs, io|
78
+ wf.before(:launch_jobs) do
90
79
  SCR.stop_on_unknown!
91
- io
92
80
  end
93
81
 
94
- wf.on(:launch_jobs) do |wf_jobs, io|
95
- io.session.jobs_launch(simulate: io.options[:dry_run])
96
- io
82
+ wf.on(:launch_jobs) do
83
+ session.jobs_launch(simulate: options[:dry_run])
97
84
  end
98
85
 
99
86
  wf.before(:post_launch) do |wf_post, io|
100
- if io.session.post_launch.empty?
87
+ next wf_post.skip! if session.post_launch.empty?
88
+
89
+ run_it = !options[:dry_run] || options.dig(:post_launch, :run)
90
+ unless run_it
101
91
  wf_post.skip!
102
- else
103
- get_people = io.options.dig(:people, :get)
104
- partial_update = get_people && get_people.dig(:type) == :partial
105
- run_it = !io.options[:dry_run] || io.options.dig(:post_launch, :run)
106
- refresh_data = !io.options[:dry_run] && partial_update
107
- if run_it
108
- if refresh_data
109
- # get target people afresh
110
- people = io.session.micro.people_refresh(people: io.people, include_created: true)
111
- io = io.base.new(people: people)
112
- else
113
- msg = "Although there are post_launch cases, data will not be refreshed before their run"
114
- if io.options[:dry_run]
115
- msg += ", because we are in dry-run (simulate)."
116
- elsif !partial_update
117
- msg += ", because it is not a partial update (-get-partial option not present)."
118
- end
119
- io.session.logger.info(msg)
120
- end
121
- else
122
- wf_post.skip!
123
- msg = "Although there are post_launch cases, they will NOT be RUN"
92
+ log(:info) {
93
+ msg = "Although there are post_launch cases, they will NOT be RUN"
94
+ msg += ", because we are in dry-run (simulate)." if options[:dry_run]
95
+ msg
96
+ }
97
+ next
98
+ end
99
+
100
+ get_people = options.dig(:people, :get)
101
+ partial_update = get_people && get_people.dig(:type) == :partial
102
+ refresh_data = !options[:dry_run] && partial_update
103
+
104
+ unless refresh_data
105
+ log(:info) {
106
+ msg = "Although there are post_launch cases, data will not be refreshed before their run"
124
107
  if io.options[:dry_run]
125
- msg+= ", because we are in dry-run (simulate)."
108
+ msg += ", because we are in dry-run (simulate)."
109
+ elsif !partial_update
110
+ msg += ", because it is not a partial update (-get-partial option not present)."
126
111
  end
127
- io.session.logger.info(msg)
128
- end
112
+ msg
113
+ }
114
+ next
129
115
  end
130
- io
116
+
117
+ # get target people afresh
118
+ peo_aux = session.micro.people_refresh(people: people, include_created: true)
119
+ io.base.new(people: peo_aux)
131
120
  end
132
121
 
133
122
  wf.for(:post_launch) do |wf_post|
134
-
135
- wf_post.on(:usecases) do |wf_postcases, io|
136
- io.session.post_launch.each do |use|
137
- begin
138
- io = use.launch(io: io).base
139
- rescue Eco::API::UseCases::BaseIO::MissingParameter => e
140
- if e.required == :people
141
- io.session.logger.debug("Skipping use case '#{use.name}' -- no base people detected for the current run")
142
- else
143
- raise
144
- end
145
- end
123
+ wf_post.on(:usecases) do |_wf_pu, io|
124
+ session.post_launch.each do |use|
125
+ use.launch(io: io).base
126
+ rescue Eco::API::UseCases::BaseIO::MissingParameter => e
127
+ raise unless e.required == :people
128
+ log(:debug) {
129
+ "Skipping use case '#{use.name}' -- no base people detected for the current run"
130
+ }
146
131
  end
147
- io
148
132
  end
149
133
 
150
- wf_post.on(:launch_jobs) do |wf_postlaunch, io|
151
- io.session.jobs_launch(simulate: io.options[:dry_run])
152
- io
134
+ wf_post.on(:launch_jobs) do |_wf_pl, io|
135
+ session.jobs_launch(simulate: options[:dry_run])
153
136
  end
154
137
  end
155
138
 
156
- wf.on(:report) do |wf_report, io|
157
- io.tap do |_io|
158
- if file = io.options.dig(:report, :people, :csv)
159
- io.options.deep_merge!(export: {
160
- options: {internal_names: true, nice_header: true, split_schemas: true},
161
- file: {name: file, format: :csv}
162
- })
163
- aux_io = io.new(people: io.people.updated_or_created)
164
- io.session.process_case("to-csv", io: aux_io, type: :export)
165
- end
139
+ wf.on(:report) do |_wf_rep, io|
140
+ if file = options.dig(:report, :people, :csv)
141
+ options.deep_merge!(export: {
142
+ options: {internal_names: true, nice_header: true, split_schemas: true},
143
+ file: {name: file, format: :csv}
144
+ })
145
+ aux_io = io.new(people: people.updated_or_created)
146
+ session.process_case("to-csv", io: aux_io, type: :export)
166
147
  end
167
148
  end
168
149
 
169
- wf.on(:end) do |wf_end, io|
170
- get_people = io.options.dig(:people, :get)
150
+ wf.on(:end) do |_wf_end, io|
151
+ get_people = options.dig(:people, :get)
171
152
  partial_update = get_people && get_people.dig(:type) == :partial
172
153
 
173
- unless !io.options[:end_get] || io.options[:dry_run] || partial_update
174
- people_update_cases = config.usecases.active(io: io).any? do |usecase, data|
175
- [:transform, :sync].any? {|type| usecase.type == type}
154
+ unless !options[:end_get] || options[:dry_run] || partial_update
155
+ people_update_cases = cli.config.usecases.active(io: io).any? do |usecase, data|
156
+ [:transform, :sync].any? { |type| usecase.type == type }
176
157
  end
177
158
 
178
159
  if !people_update_cases
179
160
  # Prevent getting people when there were no use cases that used them
180
- io.session.logger.info("Won't be recaching people, as there haven't been any targetted updates")
181
- elsif !io.people
182
- people = io.session.micro.people_cache
183
- io = io.new(people: people)
161
+ log(:info) {
162
+ "Won't be recaching people, as there haven't been any targetted updates"
163
+ }
164
+ elsif !people
165
+ people = session.micro.people_cache
166
+ io.new(people: people)
184
167
  end
185
168
  end
186
- io
187
169
  end
188
170
  end
189
171
  end
@@ -1,33 +1,43 @@
1
1
  module Eco::Data::Locations::NodeBase
2
2
  module TagValidations
3
+ include Eco::Language::AuxiliarLogger
4
+
3
5
  ALLOWED_CHARACTERS = "A-Za-z0-9 &_'\/.-"
4
6
  VALID_TAG_REGEX = /^[#{ALLOWED_CHARACTERS}]+$/
5
7
  INVALID_TAG_REGEX = /[^#{ALLOWED_CHARACTERS}]+/
6
8
  VALID_TAG_CHARS = /[#{ALLOWED_CHARACTERS}]+/
7
9
  DOUBLE_BLANKS = /\s\s+/
8
10
 
9
- def clean_id(str, notify: true)
11
+ def clean_id(str, notify: true, ref: '')
10
12
  blanks_x2 = has_double_blanks?(str)
11
13
  partial = replace_not_allowed(str)
12
14
  remove_double_blanks(partial).tap do |result|
13
15
  next unless notify
14
- next if invalid_warned?
16
+ next if invalid_warned?(str)
15
17
  if partial != str
16
18
  invalid_chars = identify_invalid_characters(str)
17
- puts "• (Row: #{self.row_num}) Invalid characters _#{invalid_chars}_ (removed): '#{str}' (converted to '#{result}')"
19
+ log(:warn) {
20
+ "• #{ref}Invalid characters _#{invalid_chars}_ <<_removed_: '#{str}' :_converted_>> '#{result}'"
21
+ }
18
22
  elsif blanks_x2
19
- puts "• (Row: #{self.row_num}) Double blanks (removed): '#{str}' (converted to '#{result}')"
23
+ log(:warn) {
24
+ "• #{ref}Double blanks removed: '#{str}' :_converted_>> '#{result}'"
25
+ }
20
26
  end
21
- invalid_warned!
27
+ invalid_warned!(str)
22
28
  end
23
29
  end
24
30
 
25
- def invalid_warned?
26
- @invalid_warned ||= false
31
+ def invalid_warned?(str)
32
+ invalid_warned[str] ||= false
33
+ end
34
+
35
+ def invalid_warned!(str)
36
+ invalid_warned[str] = true
27
37
  end
28
38
 
29
- def invalid_warned!
30
- @invalid_warned = true
39
+ def invalid_warned
40
+ @invalid_warned ||= {}
31
41
  end
32
42
 
33
43
  def has_double_blanks?(str)