eco-helpers 2.7.23 → 2.7.25

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.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +19 -5
  3. data/lib/eco/api/common/people/person_entry.rb +2 -1
  4. data/lib/eco/api/common/session/base_session.rb +1 -0
  5. data/lib/eco/api/common/session/helpers/prompt_user.rb +3 -1
  6. data/lib/eco/api/common/session/helpers.rb +0 -9
  7. data/lib/eco/api/common/session/logger.rb +2 -0
  8. data/lib/eco/api/microcases/account_excluded.rb +2 -0
  9. data/lib/eco/api/microcases/append_usergroups.rb +4 -6
  10. data/lib/eco/api/microcases/core_excluded.rb +2 -1
  11. data/lib/eco/api/microcases/fix_default_group.rb +13 -14
  12. data/lib/eco/api/microcases/people_cache.rb +10 -3
  13. data/lib/eco/api/microcases/people_load.rb +21 -7
  14. data/lib/eco/api/microcases/people_refresh.rb +11 -3
  15. data/lib/eco/api/microcases/people_search.rb +24 -10
  16. data/lib/eco/api/microcases/person_update.rb +8 -4
  17. data/lib/eco/api/microcases/preserve_default_tag.rb +9 -9
  18. data/lib/eco/api/microcases/preserve_policy_groups.rb +14 -14
  19. data/lib/eco/api/microcases/refresh_default_tag.rb +11 -12
  20. data/lib/eco/api/microcases/s3upload_targets.rb +3 -2
  21. data/lib/eco/api/microcases/set_account.rb +6 -7
  22. data/lib/eco/api/microcases/strict_search.rb +0 -1
  23. data/lib/eco/api/microcases/take_email_from_account.rb +46 -27
  24. data/lib/eco/api/microcases/with_each.rb +35 -23
  25. data/lib/eco/api/microcases/with_each_leaver.rb +1 -1
  26. data/lib/eco/api/microcases/with_each_present.rb +6 -2
  27. data/lib/eco/api/microcases/with_each_starter.rb +7 -3
  28. data/lib/eco/api/microcases/with_each_subordinate.rb +0 -1
  29. data/lib/eco/api/microcases/with_supervisor.rb +0 -1
  30. data/lib/eco/api/microcases.rb +0 -2
  31. data/lib/eco/api/organization/login_providers.rb +23 -5
  32. data/lib/eco/api/session.rb +1 -1
  33. data/lib/eco/cli_default/input.rb +17 -14
  34. data/lib/eco/cli_default/options.rb +41 -23
  35. data/lib/eco/cli_default/people.rb +50 -12
  36. data/lib/eco/cli_default/people_filters.rb +1 -1
  37. data/lib/eco/cli_default/workflow.rb +4 -0
  38. data/lib/eco/data/files/helpers.rb +1 -0
  39. data/lib/eco/version.rb +1 -1
  40. metadata +1 -1
@@ -1,31 +1,69 @@
1
+ MAX_GET_PARTIAL = 12_000
2
+
1
3
  ASSETS.cli.config do |cnf|
2
4
  cnf.people do |input, session, options|
3
- get = options.dig(:people, :get) || {}
4
- case
5
- when get == false
5
+ get = options.dig(:people, :get)
6
+ get = {} if get.nil?
7
+
8
+ from_remote = get && get[:from] == :remote
9
+ from_local = get && get[:from] == :local
10
+
11
+ get_full = from_remote && get[:type] == :full
12
+ get_partial = from_remote && get[:type] == :partial
13
+ get_by_file = from_local && get[:type] == :file
14
+
15
+ # -get-partial: validate input present and under max
16
+ if get_partial
17
+ msg = "To use -get-partial (partial updates), you need to use -entries-from"
18
+ raise msg unless input.is_a?(Enumerable)
19
+
20
+ if input.count > MAX_GET_PARTIAL
21
+ get_full = true
22
+ get_partial = false
23
+
24
+ msg = "(Optimization) "
25
+ msg << "Switching from partial to full people download. "
26
+ msg << "Input (#{input.count}) surpases MAX_GET_PARTIAL (#{MAX_GET_PARTIAL}) entries."
27
+ session.logger.info(msg)
28
+
29
+ options.deep_merge!(people: {
30
+ get: {
31
+ from: :remote,
32
+ type: :full
33
+ }
34
+ })
35
+ end
36
+ end
37
+
38
+ if get == false
6
39
  Eco::API::Organization::People.new([])
7
- when (get[:from] == :remote) && get[:type] == :full
40
+ elsif get_full
8
41
  # -get-people
9
42
  session.micro.people_cache
10
- when (get[:from] == :remote) && get[:type] == :partial
43
+ elsif get_partial
11
44
  # -get-partial
12
- unless (input && input.is_a?(Enumerable))
13
- raise "To use -get-partial (partial updates), you need to use -entries-from"
14
- end
15
45
  session.micro.people_search(input, options: options)
16
- when (get[:from] == :local) && get[:type] == :file
46
+ elsif get_by_file
17
47
  # -people-from-backup
18
48
  session.micro.people_load(get[:file], modifier: :file)
19
49
  #people = JSON.parse(File.read(get[:file]))
20
50
  #Eco::API::Organization::People.new(people)
21
51
  else
22
52
  options.deep_merge!(people: {
23
- get: {from: :local, type: :full}
53
+ get: {
54
+ from: :local,
55
+ type: :full
56
+ }
24
57
  })
25
- people = session.micro.people_load(modifier: [:newest, :save])
58
+
59
+ people = session.micro.people_load(modifier: %i[newest save])
60
+
26
61
  if people.empty?
27
62
  options.deep_merge!(people: {
28
- get: {from: :remote, type: :full}
63
+ get: {
64
+ from: :remote,
65
+ type: :full
66
+ }
29
67
  })
30
68
  people = session.micro.people_cache
31
69
  end
@@ -94,7 +94,7 @@ ASSETS.cli.config do |cnf|
94
94
  end
95
95
 
96
96
  options.deep_merge!(people: {filter: {details: {schema_id: sch_id}}})
97
- session.logger.info("Filtering people entries with schema #{session.schemas.to_name(sch_id)}")
97
+ session.logger.info("Filtering people records with schema #{session.schemas.to_name(sch_id)}")
98
98
 
99
99
  people.select do |person|
100
100
  person.details && (person.details.schema_id == sch_id)
@@ -4,6 +4,7 @@ ASSETS.cli do |cli| # rubocop:disable Metrics/BlockLength
4
4
  # default rescue
5
5
  wf.rescue do |err, io|
6
6
  next io if rescued
7
+
7
8
  rescued = true
8
9
  log(:debug) { err.patch_full_message }
9
10
  wf.run(:close, io: io)
@@ -47,11 +48,13 @@ ASSETS.cli do |cli| # rubocop:disable Metrics/BlockLength
47
48
  io.class.people_required?(usecase.type)
48
49
  end
49
50
  next if cases_with_people.empty? && !options.dig(:people, :get)
51
+
50
52
  io.new(people: cli.config.people(io: io))
51
53
  end
52
54
 
53
55
  wf_peo.on(:filter) do |_wf_pf, io|
54
56
  next unless people && !people.empty?
57
+
55
58
  io.new(people: cli.config.people_filters.process(io: io))
56
59
  end
57
60
  end
@@ -61,6 +64,7 @@ ASSETS.cli do |cli| # rubocop:disable Metrics/BlockLength
61
64
  # save partial entries -> should be native to session.workflow
62
65
  get_people = options.dig(:people, :get)
63
66
  partial_update = get_people && get_people[:type] == :partial
67
+
64
68
  if !options[:dry_run] && partial_update
65
69
  partial_file = session.config.people.partial_cache
66
70
  session.file_manager.save_json(io.people, partial_file, :timestamp)
@@ -28,6 +28,7 @@ module Eco
28
28
 
29
29
  content.scrub do |bytes|
30
30
  replacement = "<#{bytes.unpack1('H*')}>"
31
+
31
32
  if tolerance <= 0
32
33
  logger.error("There were more than 5 encoding errors in the file '#{file}'.")
33
34
  return content
data/lib/eco/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Eco
2
- VERSION = '2.7.23'.freeze
2
+ VERSION = '2.7.25'.freeze
3
3
  end
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.7.23
4
+ version: 2.7.25
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oscar Segura