eco-helpers 1.3.12 → 1.3.17

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 98a2098cebb4520b57aa8307cf4a09711fe5fb6d99e9dbd2cddaa50c0c74310e
4
- data.tar.gz: d45f4401b9626c1950e9a9dd6b601d6bece0d746bb0272b65be03ea626783a49
3
+ metadata.gz: e957c3c78a92c3cb18bed8c512ed087dd21551799a3dfa54e9cd3821045826ee
4
+ data.tar.gz: 853c05d5dd2191611b74b7e0b64037d2ad223721a8bff9e615560d13a057c2cc
5
5
  SHA512:
6
- metadata.gz: 659fb760d4f93a3acb33ea1c25ea2f489bdaffb6808e0bb1e3beab707f1c85a17c6b623f945a94e9f5ff7dc763919b83b29f7ad18678755d04c1668f1fb8394c
7
- data.tar.gz: ad7befbcad34c8abd24e3c9bd5b962876b797a3a245157817e30a3c8a559864b35c0b1269e92f842011ac7d998f17bd9f57b4a8fafc54bd149a9433575f695b3
6
+ metadata.gz: c5f83c3d8bef201c208c18116544d125633e3633abc33c519d841b766bb49777c562676591b3fe5e5037d805f43ece0233ab0af0ae8236a64a0823a55e88c9fd
7
+ data.tar.gz: 0cc7d6d8d7e3fb6e58a04e55e0f6dcfe84916c41b2d067828698e92255eb7004503be731ff46ba8d6d30ba6e9dcd1d9b6faf3df2ac6c80cf5ccf6fb48abb23f6
@@ -1,6 +1,50 @@
1
1
  # Change Log
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
+ ## [1.3.17] - 2020-07-xx
5
+
6
+ ### Added
7
+ ### Changed
8
+ - the `hris` case should not only include as `leavers` those that have account, but anyone that leaves
9
+ * as we could have active people with no account
10
+ ### Fixed
11
+ - `Eco::API::Session::Batch::Errors#errors`: fix error for empty `body` on response
12
+
13
+ ## [1.3.16] - 2020-06-26
14
+
15
+ ### Added
16
+ - `Eco::API::Common::People::Entries`, `#entry` & `#find` should allow for `strict` search (added parameter)
17
+ ### Changed
18
+ - upgraded `ecoportal-api` gem dependency to minimum version `0.5.7`
19
+ - this includes the removal of some patches
20
+ - some gems update
21
+ ### Fixed
22
+ - patched preferences (`kiosk` preferences should default to `nil`)
23
+
24
+ ## [1.3.15] - 2020-06-11
25
+
26
+ ### Added
27
+ - default usecase to export to `csv` (`-detailed`) now includes `"Supervisor Name"` column
28
+ ### Changed
29
+ ### Fixed
30
+
31
+ ## [1.3.14] - 2020-06-10
32
+
33
+ ### Added
34
+ - `Eco::API::Common::People::SupervisorHelpers` now has its methods as class methods
35
+ ### Changed
36
+ - upgraded `ecoportal-api` gem dependency to minimum version `0.5.6`
37
+ ### Fixed
38
+
39
+
40
+ ## [1.3.13] - 2020-05-29
41
+
42
+ ### Added
43
+ ### Changed
44
+ ### Fixed
45
+ - `Eco::API::Organization::TagTree#tag?` to accept `nil` by returning `false`
46
+ - `Eco::API::Common::People::DefaultParsers::DateParser` will parse to `Date` class
47
+ * it was parsing to `Time` class, while the native gem `ecoportal-api` parses as `Date` ([reference](https://gitlab.com/ecoPortal/ecoportal-api/-/blob/master/lib/ecoportal/api/v1/schema_field.rb))
4
48
  ## [1.3.11] - 2020-05-19
5
49
 
6
50
  ### Added
@@ -22,16 +22,16 @@ Gem::Specification.new do |s|
22
22
  #s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
23
23
  s.require_paths = ["lib"]
24
24
 
25
- s.add_development_dependency "bundler", "~> 2.0.1"
26
- s.add_development_dependency "rspec", "~> 3", ">= 3.8"
25
+ s.add_development_dependency "bundler", "~> 2.1", ">= 2.1.3"
26
+ s.add_development_dependency "rspec", "~> 3", ">= 3.9"
27
27
  s.add_development_dependency "rake", "~> 12.3.0"
28
28
  s.add_development_dependency "yard", "~> 0.9", ">= 0.9.18"
29
29
  s.add_development_dependency "redcarpet", "~> 3.5", ">= 3.5.0"
30
30
 
31
- s.add_dependency 'ecoportal-api', '~> 0.5', '>= 0.5.5'
32
- s.add_dependency 'aws-sdk-s3', '~> 1.30', '>= 1.30.1'
33
- s.add_dependency 'aws-sdk-ses', '~> 1.14', '>= 1.14.0'
34
- s.add_dependency 'dotenv', '~> 2.6', '>= 2.6.0'
31
+ s.add_dependency 'ecoportal-api', '~> 0.5', '>= 0.5.8'
32
+ s.add_dependency 'aws-sdk-s3', '~> 1', '>= 1.64.0'
33
+ s.add_dependency 'aws-sdk-ses', '~> 1', '>= 1.29.0'
34
+ s.add_dependency 'dotenv', '~> 2.7', '>= 2.7.0'
35
35
  s.add_dependency 'net-sftp', '~> 2.1', '>= 2.1.2'
36
36
 
37
37
  end
@@ -19,7 +19,7 @@ module Eco
19
19
 
20
20
  def parse_date(value)
21
21
  begin
22
- (value.to_s.empty?) ? nil : Time.parse(value)
22
+ (value.to_s.empty?) ? nil : Date.parse(value)
23
23
  rescue
24
24
  nil
25
25
  end
@@ -50,23 +50,28 @@ module Eco
50
50
  end
51
51
 
52
52
  # Search function to find an `entry` based on one of different options
53
- def entry(id: nil, external_id: nil, email: nil)
53
+ def entry(id: nil, external_id: nil, email: nil, strict: false)
54
54
  init_caches
55
55
  pers = nil
56
56
  pers = @by_id[id]&.first if id
57
57
  pers = @by_external_id[external_id&.strip]&.first if !pers && !external_id.to_s.strip.empty?
58
- pers = @by_email[email&.downcase.strip]&.first if !pers && !email.to_s.strip.empty?
59
- pers = @by_external_id[email&.downcase.strip]&.first if !pers && !email.to_s.strip.empty?
58
+
59
+ # strict prevents taking existing user for searched person with same email
60
+ # specially useful if the organisation ensures all have external id (no need for email search)
61
+ if !pers && (!strict || external_id.to_s.strip.empty?)
62
+ pers = @by_email[email&.downcase.strip]&.first if !pers && !email.to_s.strip.empty?
63
+ pers = @by_external_id[email&.downcase.strip]&.first if !pers && !email.to_s.strip.empty?
64
+ end
60
65
  pers
61
66
  end
62
67
 
63
68
  # Search function to find an `entry` based on one of different options
64
69
  # see Eco::API::Common::People::Entries#entry
65
- def find(object)
70
+ def find(object, strict: false)
66
71
  id = object.respond_to?("id")? object.send("id") : nil
67
72
  external_id = object.respond_to?("external_id")? object.send("external_id") : nil
68
73
  email = object.respond_to?("email")? object.send("email") : nil
69
- entry(id: id, external_id: external_id, email: email)
74
+ entry(id: id, external_id: external_id, email: email, strict: strict)
70
75
  end
71
76
 
72
77
  def exclude(object)
@@ -7,134 +7,144 @@ module Eco
7
7
  # * `external_id`
8
8
  # * `id`
9
9
  module SupervisorHelpers
10
+ def self.included(base)
11
+ base.send(:include, ClassMethods)
12
+ end
10
13
 
11
- # Reorders as follows:
12
- # 1. supervisors, people with no supervisor or where their supervisor not present
13
- # 2. subordinates
14
- def sort_by_supervisors(values, supervisors_first: true)
15
- raise "Expected non hash Enumerable. Given: #{values.class}" if values.is_a?(Hash)
16
- return [] unless values && values.is_a?(Enumerable)
17
- roam = Proc.new do |tree|
18
- [].tap do |out|
19
- sub_outs = tree.empty?? [] : tree.map {|sup, subtree| roam.call(subtree)}
20
- tree.each do |sup, subtree|
21
- sout = subtree.empty?? [] :roam.call(subtree)
22
- supervisors_first ? sout.unshift(sup) : sout.push(sup)
23
- out.concat(sout)
14
+ module ClassMethods
15
+ # Reorders as follows:
16
+ # 1. supervisors, people with no supervisor or where their supervisor not present
17
+ # 2. subordinates
18
+ def sort_by_supervisors(values, supervisors_first: true)
19
+ raise "Expected non hash Enumerable. Given: #{values.class}" if values.is_a?(Hash)
20
+ return [] unless values && values.is_a?(Enumerable)
21
+ roam = Proc.new do |tree|
22
+ [].tap do |out|
23
+ sub_outs = tree.empty?? [] : tree.map {|sup, subtree| roam.call(subtree)}
24
+ tree.each do |sup, subtree|
25
+ sout = subtree.empty?? [] :roam.call(subtree)
26
+ supervisors_first ? sout.unshift(sup) : sout.push(sup)
27
+ out.concat(sout)
28
+ end
24
29
  end
25
30
  end
26
- end
27
31
 
28
- roam.call(supervisors_tree(values))
29
- end
32
+ roam.call(supervisors_tree(values))
33
+ end
30
34
 
31
- def tree_to_str(tree, lev: 0)
32
- raise "Required Hash tree structure. Given: #{tree.class}" unless tree.is_a?(Hash)
33
- "".tap do |str|
34
- tree.each do |entry, subtree|
35
- str << "#{" " * lev}+-- #{entry.id || entry.external_id}\n"
36
- str << tree_to_str(subtree, lev: lev + 1) unless !subtree || subtree.empty?
35
+ def tree_to_str(tree, lev: 0)
36
+ raise "Required Hash tree structure. Given: #{tree.class}" unless tree.is_a?(Hash)
37
+ "".tap do |str|
38
+ tree.each do |entry, subtree|
39
+ str << "#{" " * lev}+-- #{entry.id || entry.external_id}\n"
40
+ str << tree_to_str(subtree, lev: lev + 1) unless !subtree || subtree.empty?
41
+ end
37
42
  end
38
43
  end
39
- end
40
44
 
41
- def print_tree(tree, lev: 0)
42
- puts tree_to_str(tree)
43
- end
45
+ def print_tree(tree, lev: 0)
46
+ puts tree_to_str(tree)
47
+ end
44
48
 
45
- # Generates a `Hash` tree structure, where:
46
- # * **keys** are nodes
47
- # * **values** are `Hash` subtree structures of `key` subordinates
48
- # @note it is resilient to cyclic supervisors (it will just add the last at the top)
49
- # @param values [Enumerable<Object>] of objects with methods:
50
- # `id`, `external_id` and `supervisor_id`
51
- # @return [Hash] the tree structure
52
- def supervisors_tree(values)
53
- raise "Expected non hash Enumerable. Given: #{values.class}" if values.is_a?(Hash)
54
- return {} unless values && values.is_a?(Enumerable)
55
- idx = get_super_indexes(values)
56
-
57
- processed = []
58
- subtree = Proc.new do |entry, level, toptree|
59
- if processed.include?(entry)
60
- next {} unless toptree.key?(entry) && level > 0
61
- # needs to be moved as a child
62
- subnodes = toptree.delete(entry)
63
- processed.delete(entry)
64
- end
49
+ # Generates a `Hash` tree structure, where:
50
+ # * **keys** are nodes
51
+ # * **values** are `Hash` subtree structures of `key` subordinates
52
+ # @note it is resilient to cyclic supervisors (it will just add the last at the top)
53
+ # @param values [Enumerable<Object>] of objects with methods:
54
+ # `id`, `external_id` and `supervisor_id`
55
+ # @return [Hash] the tree structure
56
+ def supervisors_tree(values)
57
+ raise "Expected non hash Enumerable. Given: #{values.class}" if values.is_a?(Hash)
58
+ return {} unless values && values.is_a?(Enumerable)
59
+ idx = get_super_indexes(values)
60
+
61
+ processed = []
62
+ subtree = Proc.new do |entry, level, toptree|
63
+ if processed.include?(entry)
64
+ next {} unless toptree.key?(entry) && level > 0
65
+ # needs to be moved as a child
66
+ subnodes = toptree.delete(entry)
67
+ processed.delete(entry)
68
+ end
65
69
 
66
- subnodes ||= {}.tap do |tree|
67
- subs = idx[:subordinates].call(entry)
68
- processed.push(entry)
69
- next nil unless subs && !subs.empty?
70
- subs.each do |sub|
71
- sub_tree = subtree.call(sub, level + 1, toptree)
72
- tree.merge!(sub_tree)
70
+ subnodes ||= {}.tap do |tree|
71
+ subs = idx[:subordinates].call(entry)
72
+ processed.push(entry)
73
+ next nil unless subs && !subs.empty?
74
+ subs.each do |sub|
75
+ sub_tree = subtree.call(sub, level + 1, toptree)
76
+ tree.merge!(sub_tree)
77
+ end
73
78
  end
74
- end
75
79
 
76
- {entry => subnodes}
77
- end
80
+ {entry => subnodes}
81
+ end
78
82
 
79
- {}.tap do |tree|
80
- idx[:by_sup].keys.each do |sup_id|
81
- if sup = idx[:supers][sup_id]
82
- tree.merge!(subtree.call(sup, 0, tree))
83
- else
84
- idx[:by_sup][sup_id].each do |sub|
85
- tree.merge!(subtree.call(sub, 0, tree))
83
+ {}.tap do |tree|
84
+ idx[:by_sup].keys.each do |sup_id|
85
+ if sup = idx[:supers][sup_id]
86
+ tree.merge!(subtree.call(sup, 0, tree))
87
+ else
88
+ idx[:by_sup][sup_id].each do |sub|
89
+ tree.merge!(subtree.call(sub, 0, tree))
90
+ end
86
91
  end
87
92
  end
88
93
  end
89
94
  end
90
- end
91
95
 
92
- private
93
-
94
- def get_super_indexes(values)
95
- raise "Expected non hash Enumerable. Given: #{values.class}" if values.is_a?(Hash)
96
- {}.tap do |indexes|
97
- indexes[:by_id] = values.map do |e|
98
- e.id && [e.id, e]
99
- end.compact.to_h
100
- indexes[:by_ext] = values.map do |e|
101
- e.external_id && [e.external_id, e]
102
- end.compact.to_h
103
-
104
- indexes[:by_sup] = {}.tap do |by_s|
105
- values.group_by do |e|
106
- e.supervisor_id
107
- end.tap do |by_sup|
108
- by_s[nil] = by_sup.delete(nil) if by_sup.key?(nil)
109
- by_s.merge!(by_sup)
96
+ private
97
+
98
+ def get_super_indexes(values)
99
+ raise "Expected non hash Enumerable. Given: #{values.class}" if values.is_a?(Hash)
100
+ {}.tap do |indexes|
101
+ indexes[:by_id] = values.map do |e|
102
+ e.id && [e.id, e]
103
+ end.compact.to_h
104
+ indexes[:by_ext] = values.map do |e|
105
+ e.external_id && [e.external_id, e]
106
+ end.compact.to_h
107
+
108
+ indexes[:by_sup] = {}.tap do |by_s|
109
+ values.group_by do |e|
110
+ e.supervisor_id
111
+ end.tap do |by_sup|
112
+ by_s[nil] = by_sup.delete(nil) if by_sup.key?(nil)
113
+ by_s.merge!(by_sup)
114
+ end
110
115
  end
111
- end
112
116
 
113
- indexes[:supers] = {}.tap do |sups|
114
- indexes[:by_ext].select do |ext, e|
115
- ext && indexes[:by_sup].key?(ext)
116
- end.tap {|found| sups.merge!(found)}
117
- indexes[:by_id].select do |id, e|
118
- id && indexes[:by_sup].key?(id)
119
- end.tap {|found| sups.merge!(found)}
120
- end
117
+ indexes[:supers] = {}.tap do |sups|
118
+ indexes[:by_ext].select do |ext, e|
119
+ ext && indexes[:by_sup].key?(ext)
120
+ end.tap {|found| sups.merge!(found)}
121
+ indexes[:by_id].select do |id, e|
122
+ id && indexes[:by_sup].key?(id)
123
+ end.tap {|found| sups.merge!(found)}
124
+ end
121
125
 
122
- indexes[:is_super] = Proc.new do |entry|
123
- !!(indexes[:supers][entry.id] || indexes[:supers][entry.external_id])
124
- end
126
+ indexes[:is_super] = Proc.new do |entry|
127
+ !!(indexes[:supers][entry.id] || indexes[:supers][entry.external_id])
128
+ end
125
129
 
126
- indexes[:subordinates] = Proc.new do |entry|
127
- subs = nil
128
- if sup = indexes[:supers][entry.id] || indexes[:supers][entry.external_id]
129
- subs ||= indexes[:by_sup][sup.id] unless !sup.id
130
- subs ||= indexes[:by_sup][sup.external_id] unless !sup.external_id
130
+ indexes[:subordinates] = Proc.new do |entry|
131
+ subs = nil
132
+ if sup = indexes[:supers][entry.id] || indexes[:supers][entry.external_id]
133
+ subs ||= indexes[:by_sup][sup.id] unless !sup.id
134
+ subs ||= indexes[:by_sup][sup.external_id] unless !sup.external_id
135
+ end
136
+ subs
131
137
  end
132
- subs
133
138
  end
139
+
134
140
  end
135
141
 
136
142
  end
137
143
 
144
+ class << self
145
+ include SupervisorHelpers::ClassMethods
146
+ end
147
+
138
148
  end
139
149
  end
140
150
  end
@@ -1,6 +1,4 @@
1
- require 'ecoportal/api'
2
1
  require_relative 'ecoportal_api/base_model'
3
- require_relative 'ecoportal_api/external_people'
4
2
  require_relative 'ecoportal_api/external_person'
5
3
  require_relative 'ecoportal_api/internal_person'
6
4
  require_relative 'ecoportal_api/account_preferences'
@@ -1,47 +1,28 @@
1
1
  module Ecoportal
2
2
  module API
3
3
  class Internal
4
- class Preferences
4
+ class Preferences < Common::BaseModel
5
+ passthrough :kiosk_enabled, :kiosk_workflow_message, :kiosk_create_button_label,
6
+ :kiosk_create_button_help, :kiosk_return_button_label, :kiosk_return_button_help,
7
+ :kiosk_dashboard_button_label, :kiosk_dashboard_button_help
8
+
5
9
  [
6
10
  :show_sidebar,
7
11
  :show_shortcuts,
8
12
  :show_coming_soon,
9
13
  :show_recently_visited_forms,
10
14
  :show_tasks,
11
- ].each do |field|
12
- key = field.to_s
15
+ :show_task_bubbles
16
+ ].map(&:to_s).each do |field|
13
17
  define_method(field) do
14
- if doc.key?(key)
15
- doc[key]
18
+ if doc.key?(field)
19
+ doc[field]
16
20
  else
17
21
  true
18
22
  end
19
23
  end
20
24
  define_method("#{field}=") do |value|
21
- doc[key] = !!value
22
- end
23
- end
24
-
25
- [
26
- :kiosk_enabled,
27
- :kiosk_workflow_message,
28
- :kiosk_create_button_label,
29
- :kiosk_create_button_help,
30
- :kiosk_return_button_label,
31
- :kiosk_return_button_help,
32
- :kiosk_dashboard_button_label,
33
- :kiosk_dashboard_button_help
34
- ].each do |field|
35
- key = field.to_s
36
- define_method(field) do
37
- if doc.key?(key)
38
- doc[key]
39
- else
40
- nil
41
- end
42
- end
43
- define_method("#{field}=") do |value|
44
- doc[key] = !!value
25
+ doc[field] = !!value
45
26
  end
46
27
  end
47
28
 
@@ -62,7 +62,7 @@ module Eco
62
62
  # @param key [String] tag to verify.
63
63
  # @return [Boolean]
64
64
  def tag?(key)
65
- @hash_tags.key?(key.upcase)
65
+ @hash_tags.key?(key&.upcase)
66
66
  end
67
67
 
68
68
  # Finds a subtree node.
@@ -69,13 +69,15 @@ module Eco
69
69
 
70
70
  def errors
71
71
  entries.each_with_object([]) do |entry, arr|
72
- if errs = status[entry].body["errors"]
73
- errs.each do |msg|
74
- arr.push({
75
- type: klass = Eco::API::Error.get_type(msg),
76
- err: klass.new(err_msg: msg, entry: entry, session: session),
77
- entry: entry
78
- })
72
+ if body = status[entry].body
73
+ if errs = body["errors"]
74
+ errs.each do |msg|
75
+ arr.push({
76
+ type: klass = Eco::API::Error.get_type(msg),
77
+ err: klass.new(err_msg: msg, entry: entry, session: session),
78
+ entry: entry
79
+ })
80
+ end
79
81
  end
80
82
  end
81
83
  end
@@ -69,7 +69,7 @@ module Eco
69
69
  if session.tagtree
70
70
  person.account.default_tag = session.tagtree.default_tag(*person.filter_tags)
71
71
  else
72
- tags = person.filter_tags
72
+ tags = person.filter_tags || []
73
73
  person.account.default_tag = tags.first unless tags.length > 1
74
74
  end
75
75
  end
@@ -11,17 +11,18 @@ module Eco
11
11
  supers = session.job_group("post").new("supers", usecase: usecase, type: :update, sets: :core)
12
12
  leavers = session.job_group("post").new("leavers", usecase: usecase, type: :update, sets: :account)
13
13
 
14
- people.users.each_with_index do |person, i|
15
- if !entries.find(person)
14
+ strict_search = session.config.people.strict_search? && (!options[:search]&.key?(:strict) || options.dig(:search, :strict))
15
+ pgs = session.policy_groups
16
+
17
+ people.each_with_index do |person, i|
18
+ if !entries.find(person, strict: strict_search)
16
19
  leavers.add(person) do |person|
17
20
  person.supervisor_id = nil
18
- person.account = nil
21
+ person.account = nil if person.account
19
22
  end
20
23
  end
21
24
  end
22
25
 
23
- strict_search = session.config.people.strict_search? && (!options[:search]&.key?(:strict) || options.dig(:search, :strict))
24
- pgs = session.policy_groups
25
26
 
26
27
  if session.config.people.default_usergroup?
27
28
  def_id = pgs.to_id(session.config.people.default_usergroup)
@@ -84,7 +85,7 @@ module Eco
84
85
  if session.tagtree
85
86
  person.account.default_tag = session.tagtree.default_tag(*person.filter_tags)
86
87
  else
87
- tags = person.filter_tags
88
+ tags = person.filter_tags || []
88
89
  person.account.default_tag = tags.first unless tags.length > 1
89
90
  end
90
91
  end
@@ -30,8 +30,12 @@ module Eco
30
30
  update = session.job_group("main").new("update", usecase: usecase, type: :update, sets: :account)
31
31
 
32
32
  people.each_with_index do |person, i|
33
- #next unless person.id == "5c527ba63f7690001243f5b2"
34
- person.account.default_tag = session.tagtree.default_tag(*person.filter_tags)
33
+ if session.tagtree
34
+ person.account.default_tag = session.tagtree.default_tag(*person.filter_tags)
35
+ else
36
+ tags = person.filter_tags || []
37
+ person.account.default_tag = tags.first unless tags.length > 1
38
+ end
35
39
  update.add(person)
36
40
  end
37
41
 
@@ -42,7 +42,7 @@ module Eco
42
42
  csv << session.new_entry(person, dependencies: deps).to_hash.values
43
43
  end
44
44
  end
45
- true
45
+ exit(0)
46
46
  end
47
47
  end
48
48
 
@@ -24,21 +24,31 @@ module Eco
24
24
  CSV.open(file, "w") do |csv|
25
25
  deps = {"supervisor_id" => {people: people}}
26
26
  header = session.new_entry(people.first, dependencies: deps).to_hash.keys
27
+ header += ["Subordinates"]
28
+ header += ["Supervisor Name"]
27
29
  header += abilities
28
30
  header += ["Login Methods"] if login_providers.any_optional?
29
- header += ["Subordinates"]
30
31
  header += ["Landing Page"]
31
32
 
32
33
  csv << header
33
34
  people.each do |person|
34
35
  data = session.new_entry(person, dependencies: deps).to_hash.values
36
+
37
+ data.push(person.subordinates)
38
+ super_id = person.supervisor_id
39
+ if supervisor = people.person(id: super_id, external_id: super_id)
40
+ data.push(supervisor.name)
41
+ else
42
+ data.push("")
43
+ end
44
+
35
45
  person_abilities = (person.account && person.account.permissions_custom) || {}
36
46
  data += abilities.map {|key| person_abilities[key] || "no access"}
47
+
37
48
  if login_providers.any_optional?
38
49
  logins = (person.account && person.account.login_provider_ids) || []
39
50
  data.push(login_providers.to_name(logins).join("|"))
40
51
  end
41
- data.push(person.subordinates)
42
52
 
43
53
  if person.account && landing_id = person.account.landing_page_id
44
54
  data.push(landing_id)
@@ -47,7 +57,7 @@ module Eco
47
57
  csv << data
48
58
  end
49
59
  end
50
- true
60
+ exit(0)
51
61
  end
52
62
  end
53
63
 
@@ -68,7 +68,7 @@ module Eco
68
68
  if session.tagtree
69
69
  person.account.default_tag = session.tagtree.default_tag(*person.filter_tags)
70
70
  else
71
- tags = person.filter_tags
71
+ tags = person.filter_tags || []
72
72
  person.account.default_tag = tags.first unless tags.length > 1
73
73
  end
74
74
  end
@@ -77,7 +77,7 @@ module Eco
77
77
  if session.tagtree
78
78
  person.account.default_tag = session.tagtree.default_tag(*person.filter_tags)
79
79
  else
80
- tags = person.filter_tags
80
+ tags = person.filter_tags || []
81
81
  person.account.default_tag = tags.first unless tags.length > 1
82
82
  end
83
83
  end
@@ -1,3 +1,3 @@
1
1
  module Eco
2
- VERSION = "1.3.12"
2
+ VERSION = "1.3.17"
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: 1.3.12
4
+ version: 1.3.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oscar Segura
@@ -16,14 +16,20 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 2.0.1
19
+ version: '2.1'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 2.1.3
20
23
  type: :development
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
27
  - - "~>"
25
28
  - !ruby/object:Gem::Version
26
- version: 2.0.1
29
+ version: '2.1'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 2.1.3
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: rspec
29
35
  requirement: !ruby/object:Gem::Requirement
@@ -33,7 +39,7 @@ dependencies:
33
39
  version: '3'
34
40
  - - ">="
35
41
  - !ruby/object:Gem::Version
36
- version: '3.8'
42
+ version: '3.9'
37
43
  type: :development
38
44
  prerelease: false
39
45
  version_requirements: !ruby/object:Gem::Requirement
@@ -43,7 +49,7 @@ dependencies:
43
49
  version: '3'
44
50
  - - ">="
45
51
  - !ruby/object:Gem::Version
46
- version: '3.8'
52
+ version: '3.9'
47
53
  - !ruby/object:Gem::Dependency
48
54
  name: rake
49
55
  requirement: !ruby/object:Gem::Requirement
@@ -107,7 +113,7 @@ dependencies:
107
113
  version: '0.5'
108
114
  - - ">="
109
115
  - !ruby/object:Gem::Version
110
- version: 0.5.5
116
+ version: 0.5.8
111
117
  type: :runtime
112
118
  prerelease: false
113
119
  version_requirements: !ruby/object:Gem::Requirement
@@ -117,67 +123,67 @@ dependencies:
117
123
  version: '0.5'
118
124
  - - ">="
119
125
  - !ruby/object:Gem::Version
120
- version: 0.5.5
126
+ version: 0.5.8
121
127
  - !ruby/object:Gem::Dependency
122
128
  name: aws-sdk-s3
123
129
  requirement: !ruby/object:Gem::Requirement
124
130
  requirements:
125
131
  - - "~>"
126
132
  - !ruby/object:Gem::Version
127
- version: '1.30'
133
+ version: '1'
128
134
  - - ">="
129
135
  - !ruby/object:Gem::Version
130
- version: 1.30.1
136
+ version: 1.64.0
131
137
  type: :runtime
132
138
  prerelease: false
133
139
  version_requirements: !ruby/object:Gem::Requirement
134
140
  requirements:
135
141
  - - "~>"
136
142
  - !ruby/object:Gem::Version
137
- version: '1.30'
143
+ version: '1'
138
144
  - - ">="
139
145
  - !ruby/object:Gem::Version
140
- version: 1.30.1
146
+ version: 1.64.0
141
147
  - !ruby/object:Gem::Dependency
142
148
  name: aws-sdk-ses
143
149
  requirement: !ruby/object:Gem::Requirement
144
150
  requirements:
145
- - - ">="
146
- - !ruby/object:Gem::Version
147
- version: 1.14.0
148
151
  - - "~>"
149
152
  - !ruby/object:Gem::Version
150
- version: '1.14'
153
+ version: '1'
154
+ - - ">="
155
+ - !ruby/object:Gem::Version
156
+ version: 1.29.0
151
157
  type: :runtime
152
158
  prerelease: false
153
159
  version_requirements: !ruby/object:Gem::Requirement
154
160
  requirements:
155
- - - ">="
156
- - !ruby/object:Gem::Version
157
- version: 1.14.0
158
161
  - - "~>"
159
162
  - !ruby/object:Gem::Version
160
- version: '1.14'
163
+ version: '1'
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: 1.29.0
161
167
  - !ruby/object:Gem::Dependency
162
168
  name: dotenv
163
169
  requirement: !ruby/object:Gem::Requirement
164
170
  requirements:
165
171
  - - ">="
166
172
  - !ruby/object:Gem::Version
167
- version: 2.6.0
173
+ version: 2.7.0
168
174
  - - "~>"
169
175
  - !ruby/object:Gem::Version
170
- version: '2.6'
176
+ version: '2.7'
171
177
  type: :runtime
172
178
  prerelease: false
173
179
  version_requirements: !ruby/object:Gem::Requirement
174
180
  requirements:
175
181
  - - ">="
176
182
  - !ruby/object:Gem::Version
177
- version: 2.6.0
183
+ version: 2.7.0
178
184
  - - "~>"
179
185
  - !ruby/object:Gem::Version
180
- version: '2.6'
186
+ version: '2.7'
181
187
  - !ruby/object:Gem::Dependency
182
188
  name: net-sftp
183
189
  requirement: !ruby/object:Gem::Requirement
@@ -249,7 +255,6 @@ files:
249
255
  - lib/eco/api/common/version_patches/ecoportal_api.rb
250
256
  - lib/eco/api/common/version_patches/ecoportal_api/account_preferences.rb
251
257
  - lib/eco/api/common/version_patches/ecoportal_api/base_model.rb
252
- - lib/eco/api/common/version_patches/ecoportal_api/external_people.rb
253
258
  - lib/eco/api/common/version_patches/ecoportal_api/external_person.rb
254
259
  - lib/eco/api/common/version_patches/ecoportal_api/internal_person.rb
255
260
  - lib/eco/api/common/version_patches/exception.rb
@@ -1,38 +0,0 @@
1
- module Ecoportal
2
- module API
3
- class V1
4
- class People
5
-
6
- def job
7
- operation = Common::BatchOperation.new("/people", person_class, logger: client.logger)
8
- yield operation
9
- # The batch operation is responsible for logging the output
10
- job_id = create_job(operation)
11
- status = wait_for_job_completion(job_id)
12
-
13
- if status&.complete?
14
- operation.process_response job_result(job_id, operation)
15
- else
16
- raise "Job `#{job_id}` not complete. Probably timeout after #{JOB_TIMEOUT + 120} seconds. Current status: #{status}"
17
- end
18
- end
19
-
20
- private
21
-
22
- def wait_for_job_completion(job_id)
23
- # timeout library is evil. So we make poor-man timeout.
24
- # https://jvns.ca/blog/2015/11/27/why-rubys-timeout-is-dangerous-and-thread-dot-raise-is-terrifying/
25
- before = Time.now
26
- while true
27
- status = job_status(job_id)
28
- break status if status.complete?
29
- break status if Time.now >= before + (JOB_TIMEOUT + 120)
30
- sleep(DELAY_STATUS_CHECK)
31
- status
32
- end
33
- end
34
-
35
- end
36
- end
37
- end
38
- end