eco-helpers 2.7.24 → 2.7.25

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +12 -1
  3. data/lib/eco/api/common/session/base_session.rb +1 -0
  4. data/lib/eco/api/common/session/helpers/prompt_user.rb +3 -1
  5. data/lib/eco/api/common/session/helpers.rb +0 -9
  6. data/lib/eco/api/common/session/logger.rb +2 -0
  7. data/lib/eco/api/microcases/account_excluded.rb +2 -0
  8. data/lib/eco/api/microcases/append_usergroups.rb +4 -6
  9. data/lib/eco/api/microcases/core_excluded.rb +2 -1
  10. data/lib/eco/api/microcases/fix_default_group.rb +13 -14
  11. data/lib/eco/api/microcases/people_cache.rb +10 -3
  12. data/lib/eco/api/microcases/people_load.rb +21 -7
  13. data/lib/eco/api/microcases/people_refresh.rb +11 -3
  14. data/lib/eco/api/microcases/people_search.rb +24 -10
  15. data/lib/eco/api/microcases/person_update.rb +8 -4
  16. data/lib/eco/api/microcases/preserve_default_tag.rb +9 -9
  17. data/lib/eco/api/microcases/preserve_policy_groups.rb +14 -14
  18. data/lib/eco/api/microcases/refresh_default_tag.rb +11 -12
  19. data/lib/eco/api/microcases/s3upload_targets.rb +3 -2
  20. data/lib/eco/api/microcases/set_account.rb +6 -7
  21. data/lib/eco/api/microcases/strict_search.rb +0 -1
  22. data/lib/eco/api/microcases/take_email_from_account.rb +46 -27
  23. data/lib/eco/api/microcases/with_each.rb +15 -5
  24. data/lib/eco/api/microcases/with_each_leaver.rb +1 -1
  25. data/lib/eco/api/microcases/with_each_present.rb +6 -2
  26. data/lib/eco/api/microcases/with_each_starter.rb +7 -3
  27. data/lib/eco/api/microcases/with_each_subordinate.rb +0 -1
  28. data/lib/eco/api/microcases/with_supervisor.rb +0 -1
  29. data/lib/eco/api/microcases.rb +0 -2
  30. data/lib/eco/api/organization/login_providers.rb +23 -5
  31. data/lib/eco/api/session.rb +1 -1
  32. data/lib/eco/cli_default/input.rb +17 -14
  33. data/lib/eco/cli_default/options.rb +41 -23
  34. data/lib/eco/cli_default/people.rb +50 -12
  35. data/lib/eco/cli_default/people_filters.rb +1 -1
  36. data/lib/eco/cli_default/workflow.rb +4 -0
  37. data/lib/eco/data/files/helpers.rb +1 -0
  38. data/lib/eco/version.rb +1 -1
  39. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6576d3f9439855c0004110d104d82634733df41822acb362bc82cafcbf90d6ca
4
- data.tar.gz: e0052851a9c33b54c77bcb4577874cb765e744c40ed63b7eaa5a5fd3d59632ec
3
+ metadata.gz: f48b7df545da0ca3acf06e577b40cb29cf52efd58d9ee3de743609c9e829c2df
4
+ data.tar.gz: 6e14955bfb6ab3d824dbc5e11d899c30a1059e1a2b37931e6970461753e2d892
5
5
  SHA512:
6
- metadata.gz: 479a0ed0a903b1f05a930673e0098912df91cb66a49b1acb99d2b7c82dd531f9bcd4704f46c0a4a84ad9f8c2e12a0469ccbc1b8760cba65fae1e7e272d6575aa
7
- data.tar.gz: 5f626293d3de079368627f68eb5337abe64afde56f86248721ed3615a90d7e694cacde99fe78467e50fb4c24a8d19cb66670cffc14f63c08ab1b4735d9652041
6
+ metadata.gz: fe73ff0a71b790e686ca6bd58c553c2643cc71c99c02dd0572cc1acd29b20891a992a5edf1caa96e3d99cf622deac1ef060067f2ac3763cbc48ba1d93bfad7d5
7
+ data.tar.gz: 41a6f87ed1b0dfb5ad3b1fee16afb44d9d0ff8ab7ad6aabc59167003837434ecff523e0f177b7d15a96be6b8044e918084d9eeaade05b33c18bac736a4c11810
data/CHANGELOG.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
- ## [2.7.25] - 2024-07-xx
5
+ ## [2.7.26] - 2024-08-xx
6
6
 
7
7
  ### Added
8
8
 
@@ -10,6 +10,17 @@ All notable changes to this project will be documented in this file.
10
10
 
11
11
  ### Fixed
12
12
 
13
+ ## [2.7.25] - 2024-08-01
14
+
15
+ ### Added
16
+
17
+ - `Eco::API::Organization::LoginProviders#to_id`
18
+ - added support for `:magic_link` and `:magiclink`
19
+
20
+ ### Changed
21
+
22
+ - `-get-partial` switches to full people download when it the input file surpases `MAX_GET_PARTIAL`
23
+
13
24
  ## [2.7.24] - 2024-07-30
14
25
 
15
26
  ### Fixed
@@ -8,6 +8,7 @@ module Eco
8
8
  alias_method :enviro, :environment
9
9
 
10
10
  include Session::Helpers
11
+ include Eco::Language::AuxiliarLogger
11
12
 
12
13
  def initialize(env)
13
14
  msg = "Expected object Eco::API::Common::Session::Environment. Given: #{env.class}"
@@ -7,12 +7,13 @@ module Eco
7
7
  # Prompts user for input with option for default on timeout.
8
8
  def prompt_user(question, default:, explanation: "", timeout: nil)
9
9
  require 'timeout'
10
- response = \
10
+ response =
11
11
  if config.run_mode_remote?
12
12
  default
13
13
  else
14
14
  puts explanation
15
15
  print "#{question} "
16
+
16
17
  if timeout
17
18
  begin
18
19
  Timeout::timeout(timeout) { STDIN.gets.chop }
@@ -24,6 +25,7 @@ module Eco
24
25
  end
25
26
  end
26
27
  return response unless block_given?
28
+
27
29
  yield(response)
28
30
  end
29
31
  end
@@ -5,24 +5,15 @@ module Eco
5
5
  module Common
6
6
  module Session
7
7
  module Helpers
8
-
9
8
  class << self
10
9
  def included(base)
11
10
  base.send(:include, InstanceMethods)
12
- base.extend(ClassMethods)
13
11
  end
14
12
  end
15
13
 
16
-
17
- module ClassMethods
18
-
19
- end
20
-
21
14
  module InstanceMethods
22
15
  include Helpers::PromptUser
23
-
24
16
  end
25
-
26
17
  end
27
18
  end
28
19
  end
@@ -21,6 +21,7 @@ module Eco
21
21
  logger.formatter = format_proc(console: false) do |severity, datetime, msg, formatted_msg|
22
22
  cache.add(severity, datetime, msg, formatted_msg)
23
23
  end
24
+
24
25
  logger.level = file_level
25
26
  end
26
27
  end
@@ -54,6 +55,7 @@ module Eco
54
55
  log_file = @enviro.file_manager.dir.file(log_file) if @enviro
55
56
  FileManager.create_directory(log_file, includes_file: true)
56
57
  end
58
+
57
59
  log_file
58
60
  end
59
61
  end
@@ -10,9 +10,11 @@ module Eco
10
10
  if options.dig(:exclude, :policy_groups)
11
11
  account_excluded.push("policy_group_ids")
12
12
  end
13
+
13
14
  if options.dig(:exclude, :default_tag)
14
15
  account_excluded.push("default_tag")
15
16
  end
17
+
16
18
  if options.dig(:exclude, :login_providers)
17
19
  account_excluded.push("login_provider_ids")
18
20
  end
@@ -6,13 +6,11 @@ module Eco
6
6
  # @param person [Ecoportal::API::V1::Person] the person we want to update, carrying the changes to be done.
7
7
  # @param options [Hash] the options.
8
8
  def append_usergroups(entry, person, options)
9
- unless options.dig(:exclude, :account)
10
- if person.account
11
- person.account.policy_group_ids |= entry.policy_group_ids
12
- end
13
- end
14
- end
9
+ return if options.dig(:exclude, :account)
10
+ return unless person.account
15
11
 
12
+ person.account.policy_group_ids |= entry.policy_group_ids
13
+ end
16
14
  end
17
15
  end
18
16
  end
@@ -7,7 +7,8 @@ module Eco
7
7
  # @return [Array<String>] the core parameters that should not be included.
8
8
  def core_excluded(person, options)
9
9
  ["supervisor_id"].tap do |core_excluded|
10
- can_exclude = person.new?? ["filter_tags"] : ["name", "external_id", "email", "filter_tags"]
10
+ can_exclude = person.new?? ["filter_tags"] : %w[name external_id email filter_tags]
11
+
11
12
  exclusions = can_exclude.select do |attr|
12
13
  options.dig(:exclude, attr.to_sym)
13
14
  end
@@ -6,29 +6,28 @@ module Eco
6
6
  # @param person [Ecoportal::API::V1::Person] the person we want to update, carrying the changes to be done.
7
7
  # @param options [Hash] the options.
8
8
  def fix_default_group(entry, person, options)
9
- unless options.dig(:exclude, :account)
10
- unless options.dig(:exclude, :policy_groups) && !person.new?
11
- end_pg_ids = person.account.policy_group_ids
9
+ return if options.dig(:exclude, :account)
10
+ return if options.dig(:exclude, :policy_groups) && !person.new?
12
11
 
13
- if person.account_added? && __def_usergroup_id && !entry.policy_group_ids?
14
- # on account creation, if missing policy_group_ids column in the input
15
- # use default_usergroup, if it's defined
16
- end_pg_ids = [__def_usergroup_id]
17
- end
12
+ end_pg_ids = person.account.policy_group_ids
18
13
 
19
- person.account.policy_group_ids = end_pg_ids
20
- end
14
+ if person.account_added? && __def_usergroup_id && !entry.policy_group_ids?
15
+ # on account creation, if missing policy_group_ids column in the input
16
+ # use default_usergroup, if it's defined
17
+ end_pg_ids = [__def_usergroup_id]
21
18
  end
19
+
20
+ person.account.policy_group_ids = end_pg_ids
22
21
  end
23
22
 
24
23
  private
25
24
 
26
25
  def __def_usergroup_id
27
- @def_usergroup_id ||= if session.config.people.default_usergroup?
28
- session.policy_groups.to_id(session.config.people.default_usergroup)
29
- end
26
+ @__def_usergroup_id ||=
27
+ if session.config.people.default_usergroup?
28
+ session.policy_groups.to_id(session.config.people.default_usergroup)
29
+ end
30
30
  end
31
-
32
31
  end
33
32
  end
34
33
  end
@@ -5,17 +5,24 @@ module Eco
5
5
  # @param filename [String] the name of the file where the data should be cached.
6
6
  # @return [Eco::API::Organization::People] the `People` object with the data.
7
7
  def people_cache(filename = enviro.config.people.cache)
8
- logger.info("Going to get all the people via API")
8
+ log(:info) { "Going to get all the people via API" }
9
9
 
10
10
  start = Time.now
11
11
  people = session.batch.get_people
12
12
  secs = (Time.now - start).round(3)
13
13
  cnt = people.count
14
14
  per_sec = (cnt.to_f / secs).round(2)
15
- logger.info("Loaded #{cnt} people in #{secs} seconds (#{per_sec} people/sec)")
15
+
16
+ log(:info) {
17
+ "Loaded #{cnt} people in #{secs} seconds (#{per_sec} people/sec)"
18
+ }
16
19
 
17
20
  file = file_manager.save_json(people, filename, :timestamp)
18
- logger.info("#{people.length} people loaded and saved locally to #{file}.")
21
+
22
+ log(:info) {
23
+ "#{people.length} people loaded and saved locally to #{file}."
24
+ }
25
+
19
26
  Eco::API::Organization::People.new(people)
20
27
  end
21
28
  end
@@ -4,7 +4,7 @@ module Eco
4
4
  # Helper to load `People` that works in different phases:
5
5
  # 1. first tries to get the newest cached file that follows `filename` pattern
6
6
  # - if not the newest, it tries to find the specific filename
7
- # 2. if it succeeds to identif a cached file, it loads it
7
+ # 2. if it succeeds to identify a cached file, it loads it
8
8
  # - if it fails, it tries to get people from the server
9
9
  # @note
10
10
  # - `filename` will be relative to the working directory (the one of the session `enviro` set by the user).
@@ -25,27 +25,37 @@ module Eco
25
25
 
26
26
  if file
27
27
  file_manager.load_json(file).tap do |people|
28
- logger.info("#{people&.length} people loaded from file #{file}") if people.is_a?(Array)
28
+ next unless people.is_a?(Array)
29
+
30
+ log(:info) {
31
+ "#{people&.length} people loaded from file #{file}"
32
+ }
29
33
  end
30
34
  else
31
- logger.error("could not find the file #{file_manager.dir.file(filename)}")
35
+ log(:error) {
36
+ "could not find the file #{file_manager.dir.file(filename)}"
37
+ }
38
+
32
39
  exit unless modifier.include?(:api)
33
40
 
34
41
  people_load(modifier: modifier - %i[newest file])
35
42
  end
36
43
  when modifier.include?(:api)
37
- logger.info("Going to get all the people via API (load)")
44
+ log(:info) { "Going to get all the people via API (load)" }
38
45
 
39
46
  start = Time.now
40
47
  session.batch.get_people.tap do |people|
41
48
  secs = (Time.now - start).round(3)
42
49
  cnt = people.count
43
50
  per_sec = (cnt.to_f / secs).round(2)
44
- logger.info("Loaded #{cnt} people in #{secs} seconds (#{per_sec} people/sec)")
51
+
52
+ log(:info) {
53
+ "Loaded #{cnt} people in #{secs} seconds (#{per_sec} people/sec)"
54
+ }
45
55
 
46
56
  if modifier.include?(:save) && people && people.length.positive?
47
57
  file = file_manager.save_json(people, filename, :timestamp)
48
- logger.info("#{people.length} people saved to file #{file}.")
58
+ log(:info) { "#{people.length} people saved to file #{file}." }
49
59
  end
50
60
  end
51
61
  end.then do |people|
@@ -59,7 +69,11 @@ module Eco
59
69
  if newest
60
70
  # search input file based on pattern (in case the name has a timestamp)
61
71
  file_manager.dir.newest_file(file: filename).tap do |file|
62
- logger.info("previous file found: #{file}") if file
72
+ next unless file
73
+
74
+ log(:info) {
75
+ "previous file found: #{file}"
76
+ }
63
77
  end
64
78
  else
65
79
  file_manager.dir.file(filename, should_exist: true)
@@ -26,17 +26,25 @@ module Eco
26
26
  created = people.length - ini
27
27
  msg = "Going to refresh #{people.length} people with server data"
28
28
  msg += " (including #{created} that were created)" if created.positive?
29
- logger.info(msg)
29
+ log(:info) { msg }
30
30
 
31
31
  start = Time.now
32
32
  entries = session.batch.get_people(people, silent: true)
33
33
  secs = (Time.now - start).round(3)
34
34
  cnt = entries.count
35
35
  per_sec = (cnt.to_f / secs).round(2)
36
- logger.info("Re-loaded #{cnt} people (out of #{people.length}) in #{secs} seconds (#{per_sec} people/sec)")
36
+
37
+ log(:info) {
38
+ "Re-loaded #{cnt} people (out of #{people.length}) in #{secs} seconds (#{per_sec} people/sec)"
39
+ }
37
40
 
38
41
  missing = people.length - entries.length
39
- logger.error("Missed to obtain #{missing} people during the refresh") if missing.positive?
42
+
43
+ if missing.positive?
44
+ log(:error) {
45
+ "Missed to obtain #{missing} people during the refresh"
46
+ }
47
+ end
40
48
 
41
49
  Eco::API::Organization::People.new(entries)
42
50
  end
@@ -10,36 +10,43 @@ module Eco
10
10
  # @param options [Hash] the options.
11
11
  # @param silent [Boolean] `false` if low level search messages should be shown.
12
12
  # @return [Eco::API::Organization::People] the `People` object with the found persons.
13
- def people_search(data, options: {}, silent: true) # rubocop:disable Metrics/AbcSize
14
- session.logger.info("Going to api get #{data.length} entries...")
13
+ def people_search(data, options: {}, silent: true) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
14
+ log(:info) { "Going to api get #{data.length} entries..." }
15
15
 
16
- silent = silent && data.count <= 500
16
+ silent &&= data.count <= 500
17
17
 
18
18
  start = Time.now
19
19
  people = session.batch.search(data, silent: silent).then do |status|
20
20
  secs = (Time.now - start).round(3)
21
+
21
22
  Eco::API::Organization::People.new(status.people).tap do |people| # rubocop:disable Lint/ShadowingOuterLocalVariable
22
23
  cnt = people.count
23
24
  per_sec = (cnt.to_f / secs).round(2)
25
+
24
26
  msg = "... could get #{cnt} people "
25
27
  msg << "(out of #{data.length} entries) in #{secs} seconds (#{per_sec} people/sec)"
26
- session.logger.info(msg)
28
+
29
+ log(:info) { msg }
27
30
  end
28
31
  end
29
32
 
30
33
  # get the supervisors of found people (current supervisors)
31
34
  supers = people_search_prepare_supers_request(people)
32
35
  if supers.length.positive?
33
- session.logger.info(" Going to api get #{supers.length} current supervisors...")
36
+ log(:info) {
37
+ " Going to api get #{supers.length} current supervisors..."
38
+ }
39
+
34
40
  start = Time.now
35
41
  people = session.batch.search(supers, silent: silent).then do |status|
36
42
  secs = (Time.now - start).round(3)
37
43
  found = status.people
38
44
  cnt = found.count
39
45
  per_sec = (cnt.to_f / secs).round(2)
46
+
40
47
  msg = "... could find #{cnt} current supers "
41
48
  msg << "(out of #{supers.length}) in #{secs} seconds (#{per_sec} people/sec)"
42
- session.logger.info(msg)
49
+ log(:info) { msg }
43
50
 
44
51
  people.merge(found, strict: micro.strict_search?(options))
45
52
  end
@@ -48,22 +55,29 @@ module Eco
48
55
  # get the supervisors referred in the input data (future supervisors)
49
56
  supers = people_search_prepare_supers_request(data, people)
50
57
  if supers.length.positive?
51
- session.logger.info(" Going to api get #{supers.length} supervisors as per input entries...")
52
- start = Time.now
58
+ log(:info) {
59
+ " Going to api get #{supers.length} supervisors as per input entries..."
60
+ }
53
61
 
62
+ start = Time.now
54
63
  people = session.batch.search(supers, silent: silent).then do |status|
55
64
  secs = (Time.now - start).round(3)
56
65
  found = status.people
57
66
  cnt = found.count
58
67
  per_sec = (cnt.to_f / secs).round(2)
68
+
59
69
  msg = "... could find #{cnt} input supers "
60
70
  msg << "(out of #{supers.length}) in #{secs} seconds (#{per_sec} people/sec)"
61
- session.logger.info(msg)
71
+ log(:info) { msg }
72
+
62
73
  people.merge(found, strict: micro.strict_search?(options))
63
74
  end
64
75
  end
65
76
 
66
- session.logger.info("Finally got #{people.length} people (out of #{data.length} entries)")
77
+ log(:info) {
78
+ "Finally got #{people.length} people (out of #{data.length} entries)"
79
+ }
80
+
67
81
  people
68
82
  end
69
83
 
@@ -8,8 +8,11 @@ module Eco
8
8
  # @param reason [String] why are we updating now.
9
9
  # @return [Boolean] `true` if it succeded to update, and `false` otherwise
10
10
  def person_update!(person, context: "Session", reason: "")
11
- logger.debug("#{context}, going to \"#{reason}\".\nPerson: #{person_ref(person)}")
12
- if response = api.people.update(person)
11
+ log(:debug) {
12
+ "#{context}, going to \"#{reason}\".\nPerson: #{person_ref(person)}"
13
+ }
14
+
15
+ if (response = api.people.update(person))
13
16
  if response.success?
14
17
  person.consolidate!
15
18
  true
@@ -17,14 +20,15 @@ module Eco
17
20
  msg = "#{context} Error #{response.status}: #{response.body}\n"
18
21
  msg += " -- Failed to \"#{reason}\".\n"
19
22
  msg += " • Person: #{person_ref(person)}"
20
- logger.error(msg)
23
+ log(:error) { msg }
21
24
  false
22
25
  end
23
26
  else
24
27
  msg = "#{context} Error (connection error)\n"
25
28
  msg += " -- Failed to \"#{reason}\".\n"
26
29
  msg += " • Person: #{person_ref(person)}"
27
- logger.error(msg)
30
+
31
+ log(:error) { msg }
28
32
  false
29
33
  end
30
34
  end
@@ -7,17 +7,17 @@ module Eco
7
7
  # @param person [Ecoportal::API::V1::Person] the person we want to update, carrying the changes to be done.
8
8
  # @param options [Hash] the options.
9
9
  # @return [String] the final value of `default_tag`.
10
- def preserve_default_tag(person, options)
11
- if account = person.account
12
- if account.as_update.key?("default_tag")
13
- if original = person.original_doc.dig("account", "default_tag")
14
- person.account.default_tag = original
15
- end
16
- end
10
+ def preserve_default_tag(person, _options)
11
+ return unless (account = person.account)
12
+
13
+ account.default_tag.tap do
14
+ next unless account.as_update.key?("default_tag")
15
+ next unless (original = person.original_doc.dig("account", "default_tag"))
16
+
17
+ person.account.default_tag = original
18
+ return original
17
19
  end
18
- person.account&.default_tag
19
20
  end
20
-
21
21
  end
22
22
  end
23
23
  end
@@ -8,23 +8,23 @@ module Eco
8
8
  # @param options [Hash] the options.
9
9
  # @param keep_new [Boolean] tells if it should keep the new policy groups or get rid of them.
10
10
  # @return [String] the final value of `policy_group_ids`.
11
- def preserve_policy_groups(person, options, keep_new: false)
12
- if account = person.account
13
- if account.as_update.key?("policy_group_ids")
14
- if original = person.original_doc.dig("account", "policy_group_ids")
15
- unless original.empty?
16
- if keep_new
17
- person.account.policy_group_ids += original
18
- else
19
- person.account.policy_group_ids = original
20
- end
21
- end
22
- end
11
+ def preserve_policy_groups(person, _options, keep_new: false)
12
+ return unless (account = person.account)
13
+
14
+ account.policy_group_ids.tap do
15
+ next unless account.as_update.key?("policy_group_ids")
16
+ next unless (original = person.original_doc.dig("account", "policy_group_ids"))
17
+ next if original.empty?
18
+
19
+ if keep_new
20
+ person.account.policy_group_ids += original
21
+ else
22
+ person.account.policy_group_ids = original
23
23
  end
24
+
25
+ return account.policy_group_ids
24
26
  end
25
- person.account&.policy_group_ids
26
27
  end
27
-
28
28
  end
29
29
  end
30
30
  end
@@ -8,20 +8,19 @@ module Eco
8
8
  # @param person [Ecoportal::API::V1::Person] the person we want to update, carrying the changes to be done.
9
9
  # @param options [Hash] the options
10
10
  def refresh_default_tag(entry, person, options)
11
- if person.account
12
- unless options.dig(:exclude, :account)
13
- unless options.dig(:exclude, :filter_tags) || options.dig(:exclude, :default_tag) || entry&.default_tag?
14
- if session.tagtree
15
- person.account.default_tag = session.tagtree.default_tag(*person.filter_tags)
16
- else
17
- tags = person.filter_tags || []
18
- person.account.default_tag = tags.first unless tags.length > 1
19
- end
20
- end
21
- end
11
+ return unless person.account
12
+ return if options.dig(:exclude, :account)
13
+ return if options.dig(:exclude, :filter_tags)
14
+ return if options.dig(:exclude, :default_tag)
15
+ return if entry&.default_tag?
16
+
17
+ if session.tagtree
18
+ person.account.default_tag = session.tagtree.default_tag(*person.filter_tags)
19
+ else
20
+ tags = person.filter_tags || []
21
+ person.account.default_tag = tags.first unless tags.length > 1
22
22
  end
23
23
  end
24
-
25
24
  end
26
25
  end
27
26
  end
@@ -3,14 +3,16 @@ module Eco
3
3
  class MicroCases
4
4
  # Helper to upload target files to `S3`.
5
5
  # @return [Array<String>] the paths in `S3` of the uploaded files.
6
- def s3upload_targets
6
+ def s3upload_targets # rubocop:disable Metrics/AbcSize
7
7
  [].tap do |paths|
8
8
  session.config.s3storage.target_files.each_with_object(paths) do |file, arr|
9
9
  arr.push(session.s3upload(file: file))
10
10
  end
11
+
11
12
  session.config.s3storage.target_directories.each_with_object(paths) do |folder, arr|
12
13
  arr.concat(session.s3upload(directory: folder))
13
14
  end
15
+
14
16
  session.config.s3storage.target_file_patterns.each_with_object(paths) do |pattern, arr|
15
17
  filenames = []
16
18
  case pattern
@@ -33,7 +35,6 @@ module Eco
33
35
  end
34
36
  end
35
37
  end
36
-
37
38
  end
38
39
  end
39
40
  end
@@ -5,15 +5,14 @@ module Eco
5
5
  # @param person [Ecoportal::API::V1::Person] the person we want to update, carrying the changes to be done.
6
6
  # @param options [Hash] the options.
7
7
  def set_account(entry, person, options)
8
- unless options.dig(:exclude, :account)
9
- entry.set_account(person, exclude: micro.account_excluded(person, options))
8
+ return if options.dig(:exclude, :account)
10
9
 
11
- person.account.send_invites = options[:send_invites] if options.key?(:send_invites)
12
- micro.refresh_default_tag(entry, person, options)
13
- micro.fix_default_group(entry, person, options)
14
- end
15
- end
10
+ entry.set_account(person, exclude: micro.account_excluded(person, options))
16
11
 
12
+ person.account.send_invites = options[:send_invites] if options.key?(:send_invites)
13
+ micro.refresh_default_tag(entry, person, options)
14
+ micro.fix_default_group(entry, person, options)
15
+ end
17
16
  end
18
17
  end
19
18
  end
@@ -13,7 +13,6 @@ module Eco
13
13
  soft_option = options.dig(:search, :soft) && !strict_option
14
14
  (strict_config || strict_option) && !soft_option
15
15
  end
16
-
17
16
  end
18
17
  end
19
18
  end