eco-helpers 2.7.10 → 2.7.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (27) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +14 -4
  3. data/lib/eco/api/common/session/sftp.rb +5 -1
  4. data/lib/eco/api/usecases/default/people/{clean_unknown_tags_case.rb → amend/clean_unknown_tags_case.rb} +2 -2
  5. data/lib/eco/api/usecases/default/people/{clear_abilities_case.rb → amend/clear_abilities_case.rb} +2 -2
  6. data/lib/eco/api/usecases/default/people/{refresh_case.rb → amend/refresh_case.rb} +1 -1
  7. data/lib/eco/api/usecases/default/people/amend/reinvite_sync_case.rb +11 -0
  8. data/lib/eco/api/usecases/default/people/{reinvite_trans_case.rb → amend/reinvite_trans_case.rb} +2 -2
  9. data/lib/eco/api/usecases/default/people/amend/reinvite_trans_cli.rb +4 -0
  10. data/lib/eco/api/usecases/default/people/{restore_db_case.rb → amend/restore_db_case.rb} +1 -1
  11. data/lib/eco/api/usecases/default/people/amend.rb +11 -0
  12. data/lib/eco/api/usecases/default/people/{analyse_people_case.rb → treat/analyse_people_case.rb} +1 -1
  13. data/lib/eco/api/usecases/default/people/{org_data_convert_case.rb → treat/org_data_convert_case.rb} +1 -1
  14. data/lib/eco/api/usecases/default/people/{supers_cyclic_identify_case.rb → treat/supers_cyclic_identify_case.rb} +2 -2
  15. data/lib/eco/api/usecases/default/people/{supers_hierarchy_case.rb → treat/supers_hierarchy_case.rb} +18 -17
  16. data/lib/eco/api/usecases/default/people/treat.rb +9 -0
  17. data/lib/eco/api/usecases/default/people/{change_email_case.rb → utils/change_email_case.rb} +1 -1
  18. data/lib/eco/api/usecases/default/people/{set_default_tag_case.rb → utils/set_default_tag_case.rb} +1 -1
  19. data/lib/eco/api/usecases/default/people/{switch_supervisor_case.rb → utils/switch_supervisor_case.rb} +1 -1
  20. data/lib/eco/api/usecases/default/people/{transfer_account_case.rb → utils/transfer_account_case.rb} +1 -1
  21. data/lib/eco/api/usecases/default/people/utils.rb +9 -0
  22. data/lib/eco/api/usecases/default/people.rb +4 -14
  23. data/lib/eco/api/usecases/graphql/utils/sftp.rb +14 -14
  24. data/lib/eco/version.rb +1 -1
  25. metadata +19 -16
  26. data/lib/eco/api/usecases/default/people/reinvite_sync_case.rb +0 -9
  27. data/lib/eco/api/usecases/default/people/reinvite_trans_cli.rb +0 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1e9c00a0ecc4c1fb42d808e2df03a8618c7017be7a27e6319859bd7974b3638a
4
- data.tar.gz: f9e2452935fcfc3712e53b5e5731151f1ddf6a4f946f2e1c6f8c629f48e09e9e
3
+ metadata.gz: 5d3edc9e39edaf452a269851133444e67a2c743cfa8f787723106022eb3694b1
4
+ data.tar.gz: 28f0547c71389caa7fbf2a416d52a3cc64fa191610040e3484243612cd53e523
5
5
  SHA512:
6
- metadata.gz: 4e4595657f37f057269bbd38671858700bdcc22e2755e3b365bbe69e48e017e11974a8583b5e93c09c1abf90cd4f09c0ed8ac4a853be8d471c51719fa1500e71
7
- data.tar.gz: 0e3af7794e45e62fdbb2ba06340cc7b23ea88466670eb8b597c4e279556bb5cc59dfa5f8ff0f294f77d15dfd159819590cd2228d05fa19af8a2421d4b665fa72
6
+ metadata.gz: fc3bee60f32f2c1d16c6a4f6901d9a50f8bdb8b01134f0040fbedbee8c36b7315e424f0e16c1da9ddf6a8b635b21ec0fcff6954143ee102a44ca51048d36a2ff
7
+ data.tar.gz: fa238d1c36f0deb74d94de407c06c29e75567073a289e8939ec6280362a367785a614fa99f37de1d13b63e35d5eee7fa51e3a02c84ed2aa8dec5fdfdbbf1bc7e
data/CHANGELOG.md CHANGED
@@ -1,21 +1,31 @@
1
1
  # Change Log
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
- ## [2.7.12] - 2024-05-xx
4
+
5
+ ## [2.7.13] - 2024-05-xx
5
6
 
6
7
  ### Added
7
8
  ### Changed
8
9
  ### Fixed
9
10
 
10
- ## [2.7.11] - 2024-05-20
11
+ ## [2.7.12] - 2024-05-30
11
12
 
12
13
  ### Changed
13
- - Upgrade SFTP access
14
+ - Decouple `Eco::API::UseCases::Default::People` namespace
15
+
16
+ ## [2.7.11] - 2024-05-27
14
17
 
15
- ## [2.7.10] - 2024-05-16
18
+ ### Changed\
19
+ - `Eco::API::Common::Session::SFTP#download`
20
+ - It now returns the local filename(s) of the downloaded files.
21
+ - `Eco::API::UseCases::GraphQL::Utils#sftp_download_files`
22
+ - It now returns the local filename(s) of the downloaded files.
23
+
24
+ ## [2.7.10] - 2024-05-20
16
25
 
17
26
  ### Changed
18
27
  - Temporarily silent warnings on tracking id changes (apparently the tracking locations tree is not up to date with latest version and gives false warnings)
28
+ - Upgrade SFTP access
19
29
 
20
30
  ### Fixed
21
31
  - Remove enviro from tagtree download
@@ -74,15 +74,19 @@ module Eco
74
74
  # @see Net::SFTP::Operations::Download
75
75
  # @param files [String, Array<String>] full path to remote file(s) to be downloaded
76
76
  # @param local_folder [String] local destination folder (`"."` if not specified)
77
- def download(files, local_folder: nil)
77
+ # @return [Array<String>] list of created files
78
+ def download(files, local_folder: nil, &block)
78
79
  puts "Creating local files:"
80
+ created_files = []
79
81
  [files].flatten.compact.map do |fullname|
80
82
  basename = windows_basename(fullname)
81
83
  dest_fullname = File.join(local_folder || ".", basename)
82
84
  puts " • #{dest_fullname}"
85
+ created_files << dest_fullname
83
86
  sftp_session.download(fullname, dest_fullname)
84
87
  end.each(&:wait)
85
88
  # run SSH event loop while dw.active?
89
+ created_files.tap { created_files.each(&block) }
86
90
  end
87
91
 
88
92
  # Upload a file to the specific `remote_folder`
@@ -1,4 +1,4 @@
1
- class Eco::API::UseCases::Default::People::CleanUnknownTags < Eco::API::Common::Loaders::UseCase
1
+ class Eco::API::UseCases::Default::People::Amend::CleanUnknownTags < Eco::API::Common::Loaders::UseCase
2
2
  name "clean-unknown-tags"
3
3
  type :transform
4
4
 
@@ -35,7 +35,7 @@ class Eco::API::UseCases::Default::People::CleanUnknownTags < Eco::API::Common::
35
35
  private
36
36
 
37
37
  def default_tag(person)
38
- return nil unless account = person.account
38
+ return unless (account = person.account)
39
39
  account.default_tag
40
40
  end
41
41
 
@@ -1,8 +1,8 @@
1
- class Eco::API::UseCases::Default::People::ClearAbilitiesTransCase < Eco::API::Common::Loaders::UseCase
1
+ class Eco::API::UseCases::Default::People::Amend::ClearAbilitiesTransCase < Eco::API::Common::Loaders::UseCase
2
2
  name "clear-abilities"
3
3
  type :transform
4
4
 
5
- def main(people, _session, _options, _usecase)
5
+ def main(*_args)
6
6
  clear_abilities(people.users)
7
7
  end
8
8
 
@@ -1,4 +1,4 @@
1
- class Eco::API::UseCases::Default::People::RefreshCase < Eco::API::Common::Loaders::UseCase
1
+ class Eco::API::UseCases::Default::People::Amend::RefreshCase < Eco::API::Common::Loaders::UseCase
2
2
  name "refresh"
3
3
  type :transform
4
4
 
@@ -0,0 +1,11 @@
1
+ module Eco::API::UseCases::Default::People::Amend
2
+ class ReinviteSyncCase < ReinviteTransCase
3
+ name "reinvite"
4
+ type :sync
5
+
6
+ def main(entries, *_args)
7
+ found = micro.with_each_present(entries, people, options, log_starter: true)
8
+ reinvite(found.users)
9
+ end
10
+ end
11
+ end
@@ -1,8 +1,8 @@
1
- class Eco::API::UseCases::Default::People::ReinviteTransCase < Eco::API::Common::Loaders::UseCase
1
+ class Eco::API::UseCases::Default::People::Amend::ReinviteTransCase < Eco::API::Common::Loaders::UseCase
2
2
  name "reinvite"
3
3
  type :transform
4
4
 
5
- def main(people, session, options, usecase)
5
+ def main(*_args)
6
6
  reinvite(people.users)
7
7
  end
8
8
 
@@ -0,0 +1,4 @@
1
+ class Eco::API::UseCases::Default::People::Amend::ReinviteTransCase
2
+ class Cli < Eco::API::UseCases::Cli
3
+ end
4
+ end
@@ -1,6 +1,6 @@
1
1
  # @example
2
2
  # -restore-db-from backup.json -skip-api-policies -skip-batch-policy -include-excluded -simulate
3
- class Eco::API::UseCases::Default::People::RestoreDBCase < Eco::API::Common::Loaders::UseCase
3
+ class Eco::API::UseCases::Default::People::Amend::RestoreDBCase < Eco::API::Common::Loaders::UseCase
4
4
  name "restore-db"
5
5
  type :sync
6
6
 
@@ -0,0 +1,11 @@
1
+ module Eco::API::UseCases::Default::People
2
+ module Amend
3
+ end
4
+ end
5
+
6
+ require_relative 'amend/clean_unknown_tags_case'
7
+ require_relative 'amend/clear_abilities_case'
8
+ require_relative 'amend/reinvite_trans_case'
9
+ require_relative 'amend/reinvite_sync_case'
10
+ require_relative 'amend/refresh_case'
11
+ require_relative 'amend/restore_db_case'
@@ -1,4 +1,4 @@
1
- class Eco::API::UseCases::Default::People::Analyse < Eco::API::Common::Loaders::UseCase
1
+ class Eco::API::UseCases::Default::People::Treat::Analyse < Eco::API::Common::Loaders::UseCase
2
2
  name "analyse-people"
3
3
  type :export
4
4
 
@@ -1,4 +1,4 @@
1
- class Eco::API::UseCases::Default::People::OrgDataConvertCase < Eco::API::Common::Loaders::UseCase
1
+ class Eco::API::UseCases::Default::People::Treat::OrgDataConvertCase < Eco::API::Common::Loaders::UseCase
2
2
  name "org-data-convert"
3
3
  type :import
4
4
 
@@ -1,4 +1,4 @@
1
- class Eco::API::UseCases::Default::People::SupersCyclicIdentify < Eco::API::Common::Loaders::UseCase
1
+ class Eco::API::UseCases::Default::People::Treat::SupersCyclicIdentify < Eco::API::Common::Loaders::UseCase
2
2
  name "identify-cyclic-supers"
3
3
  type :export
4
4
 
@@ -62,7 +62,7 @@ class Eco::API::UseCases::Default::People::SupersCyclicIdentify < Eco::API::Comm
62
62
 
63
63
  "".tap do |str|
64
64
  entry = set.shift
65
- str << " " * lev
65
+ str << (" " * lev)
66
66
  str << lev&.positive? ? "+-#{lev}- " : ""
67
67
  str << entry.name
68
68
  str << " (#{entry.external_id}|#{entry.email}|#{entry.id})\n"
@@ -1,10 +1,10 @@
1
- class Eco::API::UseCases::Default::People::SupersHierarchy < Eco::API::Common::Loaders::UseCase
1
+ class Eco::API::UseCases::Default::People::Treat::SupersHierarchy < Eco::API::Common::Loaders::UseCase
2
2
  name "supers-hierarchy"
3
3
  type :export
4
4
 
5
5
  attr_reader :people
6
6
 
7
- def main(people, session, options, usecase)
7
+ def main(people, _session, options, _usecase)
8
8
  options[:end_get] = false
9
9
  @people = people
10
10
 
@@ -22,20 +22,19 @@ class Eco::API::UseCases::Default::People::SupersHierarchy < Eco::API::Common::L
22
22
  end
23
23
 
24
24
  def save!(data)
25
- ext = File.extname(file).downcase.delete(".")
26
-
27
- File.open(file, "w") do |fd|
28
- if ext == "txt"
29
- create_file(data, file: file, format: :txt)
30
- elsif ext == "html"
31
- puts "html is still not supported"
32
- exit(1)
33
- create_file(data, file: file, format: :html)
34
- elsif ext == "json"
35
- puts "json is still not supported"
36
- exit(1)
37
- create_file(data, file: file, format: :json)
38
- end
25
+ ext = File.extname(file).downcase.delete(".")
26
+
27
+ case ext
28
+ when "txt"
29
+ create_file(data, file: file, format: :txt)
30
+ when "html"
31
+ puts "html is still not supported"
32
+ exit(1)
33
+ # create_file(data, file: file, format: :html)
34
+ when "json"
35
+ puts "json is still not supported"
36
+ exit(1)
37
+ # create_file(data, file: file, format: :json)
39
38
  end
40
39
  end
41
40
 
@@ -50,7 +49,9 @@ class Eco::API::UseCases::Default::People::SupersHierarchy < Eco::API::Common::L
50
49
  raise "Required Hash tree structure. Given: #{tree.class}" unless tree.is_a?(Hash)
51
50
  "".tap do |str|
52
51
  tree.each do |entry, subtree|
53
- str << "#{" " * lev}#{(lev > 0)? "+-#{lev}- " : ""}#{entry.name} (#{entry.external_id}|#{entry.email}|#{entry.id})\n"
52
+ str << "#{" " * lev}#{lev.positive? ? "+-#{lev}- " : ""}"
53
+ str << entry.name
54
+ str << " (#{entry.external_id}|#{entry.email}|#{entry.id})\n"
54
55
  str << tree_to_str(subtree, lev: lev + 1, format: format) unless !subtree || subtree.empty?
55
56
  end
56
57
  end
@@ -0,0 +1,9 @@
1
+ module Eco::API::UseCases::Default::People
2
+ module Treat
3
+ end
4
+ end
5
+
6
+ require_relative 'treat/analyse_people_case'
7
+ require_relative 'treat/supers_hierarchy_case'
8
+ require_relative 'treat/supers_cyclic_identify_case'
9
+ require_relative 'treat/org_data_convert_case'
@@ -1,4 +1,4 @@
1
- class Eco::API::UseCases::Default::People::ChangeEMailCase < Eco::API::Common::Loaders::UseCase
1
+ class Eco::API::UseCases::Default::People::Utils::ChangeEMailCase < Eco::API::Common::Loaders::UseCase
2
2
  name "change-email"
3
3
  type :sync
4
4
 
@@ -1,4 +1,4 @@
1
- class Eco::API::UseCases::Default::People::SetDefaultTagCase < Eco::API::Common::Loaders::UseCase
1
+ class Eco::API::UseCases::Default::People::Utils::SetDefaultTagCase < Eco::API::Common::Loaders::UseCase
2
2
  name "set-default-tag"
3
3
  type :transform
4
4
 
@@ -1,4 +1,4 @@
1
- class Eco::API::UseCases::Default::People::SwitchSupervisorCase < Eco::API::Common::Loaders::UseCase
1
+ class Eco::API::UseCases::Default::People::Utils::SwitchSupervisorCase < Eco::API::Common::Loaders::UseCase
2
2
  name "switch-supervisor"
3
3
  type :transform
4
4
 
@@ -1,4 +1,4 @@
1
- class Eco::API::UseCases::Default::People::TransferAccountCase < Eco::API::Common::Loaders::UseCase
1
+ class Eco::API::UseCases::Default::People::Utils::TransferAccountCase < Eco::API::Common::Loaders::UseCase
2
2
  name "transfer-account"
3
3
  type :sync
4
4
 
@@ -0,0 +1,9 @@
1
+ module Eco::API::UseCases::Default::People
2
+ module Utils
3
+ end
4
+ end
5
+
6
+ require_relative 'utils/change_email_case'
7
+ require_relative 'utils/set_default_tag_case'
8
+ require_relative 'utils/switch_supervisor_case'
9
+ require_relative 'utils/transfer_account_case'
@@ -9,17 +9,7 @@ module Eco
9
9
  end
10
10
  end
11
11
 
12
- require_relative 'people/analyse_people_case'
13
- require_relative 'people/change_email_case'
14
- require_relative 'people/clean_unknown_tags_case'
15
- require_relative 'people/clear_abilities_case'
16
- require_relative 'people/reinvite_trans_case'
17
- require_relative 'people/reinvite_sync_case'
18
- require_relative 'people/org_data_convert_case'
19
- require_relative 'people/refresh_case'
20
- require_relative 'people/restore_db_case'
21
- require_relative 'people/set_default_tag_case'
22
- require_relative 'people/supers_hierarchy_case'
23
- require_relative 'people/supers_cyclic_identify_case'
24
- require_relative 'people/switch_supervisor_case'
25
- require_relative 'people/transfer_account_case'
12
+ require_relative 'people/treat'
13
+ require_relative 'people/utils'
14
+ require_relative 'people/amend'
15
+
@@ -19,20 +19,20 @@ module Eco::API::UseCases::GraphQL::Utils
19
19
  end
20
20
  end
21
21
 
22
- def sftp_download_files(subfolder: remote_subfolder, pattern: nil, local_folder: self.local_folder)
23
- with_remote_files(subfolder: subfolder, pattern: pattern).tap do |files|
24
- next if files.empty?
25
- file_names = files.map {|file| to_remote_path(file.name, subfolder: subfolder)}
26
-
27
- log(:info) {
28
- msg = "Getting the following files into the local folder '#{local_folder}':\n"
29
- msg << " "
30
- msg << file_names.join("\n • ")
31
- msg
32
- }
33
-
34
- sftp.download(file_names, local_folder: local_folder)
35
- end
22
+ def sftp_download_files(subfolder: remote_subfolder, pattern: nil, local_folder: self.local_folder, &block)
23
+ remote_files = with_remote_files(subfolder: subfolder, pattern: pattern)
24
+ return [] if remote_files.empty?
25
+
26
+ file_names = remote_files.map {|file| to_remote_path(file.name, subfolder: subfolder)}
27
+
28
+ log(:info) {
29
+ msg = "Getting the following files into the local folder '#{local_folder}':\n"
30
+ msg << " • "
31
+ msg << file_names.join("\n • ")
32
+ msg
33
+ }
34
+
35
+ sftp.download(file_names, local_folder: local_folder, &block)
36
36
  end
37
37
 
38
38
  def sftp_move_file(source, dest)
data/lib/eco/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Eco
2
- VERSION = '2.7.10'.freeze
2
+ VERSION = '2.7.12'.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.10
4
+ version: 2.7.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oscar Segura
@@ -673,21 +673,24 @@ files:
673
673
  - lib/eco/api/usecases/default/locations/tagtree_extract_case.rb
674
674
  - lib/eco/api/usecases/default/locations/tagtree_upload_case.rb
675
675
  - lib/eco/api/usecases/default/people.rb
676
- - lib/eco/api/usecases/default/people/analyse_people_case.rb
677
- - lib/eco/api/usecases/default/people/change_email_case.rb
678
- - lib/eco/api/usecases/default/people/clean_unknown_tags_case.rb
679
- - lib/eco/api/usecases/default/people/clear_abilities_case.rb
680
- - lib/eco/api/usecases/default/people/org_data_convert_case.rb
681
- - lib/eco/api/usecases/default/people/refresh_case.rb
682
- - lib/eco/api/usecases/default/people/reinvite_sync_case.rb
683
- - lib/eco/api/usecases/default/people/reinvite_trans_case.rb
684
- - lib/eco/api/usecases/default/people/reinvite_trans_cli.rb
685
- - lib/eco/api/usecases/default/people/restore_db_case.rb
686
- - lib/eco/api/usecases/default/people/set_default_tag_case.rb
687
- - lib/eco/api/usecases/default/people/supers_cyclic_identify_case.rb
688
- - lib/eco/api/usecases/default/people/supers_hierarchy_case.rb
689
- - lib/eco/api/usecases/default/people/switch_supervisor_case.rb
690
- - lib/eco/api/usecases/default/people/transfer_account_case.rb
676
+ - lib/eco/api/usecases/default/people/amend.rb
677
+ - lib/eco/api/usecases/default/people/amend/clean_unknown_tags_case.rb
678
+ - lib/eco/api/usecases/default/people/amend/clear_abilities_case.rb
679
+ - lib/eco/api/usecases/default/people/amend/refresh_case.rb
680
+ - lib/eco/api/usecases/default/people/amend/reinvite_sync_case.rb
681
+ - lib/eco/api/usecases/default/people/amend/reinvite_trans_case.rb
682
+ - lib/eco/api/usecases/default/people/amend/reinvite_trans_cli.rb
683
+ - lib/eco/api/usecases/default/people/amend/restore_db_case.rb
684
+ - lib/eco/api/usecases/default/people/treat.rb
685
+ - lib/eco/api/usecases/default/people/treat/analyse_people_case.rb
686
+ - lib/eco/api/usecases/default/people/treat/org_data_convert_case.rb
687
+ - lib/eco/api/usecases/default/people/treat/supers_cyclic_identify_case.rb
688
+ - lib/eco/api/usecases/default/people/treat/supers_hierarchy_case.rb
689
+ - lib/eco/api/usecases/default/people/utils.rb
690
+ - lib/eco/api/usecases/default/people/utils/change_email_case.rb
691
+ - lib/eco/api/usecases/default/people/utils/set_default_tag_case.rb
692
+ - lib/eco/api/usecases/default/people/utils/switch_supervisor_case.rb
693
+ - lib/eco/api/usecases/default/people/utils/transfer_account_case.rb
691
694
  - lib/eco/api/usecases/default_cases.rb
692
695
  - lib/eco/api/usecases/default_cases/create_case.rb
693
696
  - lib/eco/api/usecases/default_cases/delete_sync_case.rb
@@ -1,9 +0,0 @@
1
- class Eco::API::UseCases::Default::People::ReinviteSyncCase < Eco::API::UseCases::Default::People::ReinviteTransCase
2
- name "reinvite"
3
- type :sync
4
-
5
- def main(entries, people, session, options, usecase)
6
- found = micro.with_each_present(entries, people, options, log_starter: true)
7
- reinvite(found.users)
8
- end
9
- end
@@ -1,4 +0,0 @@
1
- class Eco::API::UseCases::Default::People::ReinviteTransCase
2
- class Cli < Eco::API::UseCases::Cli
3
- end
4
- end