eco-helpers 2.6.3 → 2.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (172) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.rubocop.yml +95 -0
  4. data/CHANGELOG.md +135 -2
  5. data/Rakefile +13 -7
  6. data/eco-helpers.gemspec +3 -3
  7. data/lib/eco/api/common/loaders/base.rb +2 -2
  8. data/lib/eco/api/common/loaders/case_base.rb +1 -1
  9. data/lib/eco/api/common/loaders/config/workflow/mailer.rb +5 -5
  10. data/lib/eco/api/common/loaders/error_handler.rb +8 -5
  11. data/lib/eco/api/common/loaders/parser.rb +44 -22
  12. data/lib/eco/api/common/loaders/policy.rb +6 -4
  13. data/lib/eco/api/common/loaders/use_case.rb +13 -7
  14. data/lib/eco/api/common/people/base_parser.rb +0 -2
  15. data/lib/eco/api/common/people/default_parsers/boolean_parser.rb +0 -1
  16. data/lib/eco/api/common/people/default_parsers/csv_parser.rb +1 -1
  17. data/lib/eco/api/common/people/default_parsers/date_parser.rb +64 -12
  18. data/lib/eco/api/common/people/default_parsers/freemium_parser.rb +0 -1
  19. data/lib/eco/api/common/people/default_parsers/login_providers_parser.rb +13 -5
  20. data/lib/eco/api/common/people/default_parsers/multi_parser.rb +0 -1
  21. data/lib/eco/api/common/people/default_parsers/numeric_parser.rb +18 -5
  22. data/lib/eco/api/common/people/default_parsers/policy_groups_parser.rb +8 -8
  23. data/lib/eco/api/common/people/default_parsers/select_parser.rb +50 -26
  24. data/lib/eco/api/common/people/default_parsers/send_invites_parser.rb +6 -6
  25. data/lib/eco/api/common/people/default_parsers/xls_parser.rb +9 -12
  26. data/lib/eco/api/common/people/default_parsers.rb +1 -12
  27. data/lib/eco/api/common/people/entries.rb +13 -13
  28. data/lib/eco/api/common/people/entry_factory.rb +76 -45
  29. data/lib/eco/api/common/people/person_attribute_parser.rb +8 -12
  30. data/lib/eco/api/common/people/person_entry.rb +86 -75
  31. data/lib/eco/api/common/people/person_entry_attribute_mapper.rb +60 -44
  32. data/lib/eco/api/common/people/person_factory.rb +30 -22
  33. data/lib/eco/api/common/people/person_modifier.rb +11 -13
  34. data/lib/eco/api/common/people/person_parser.rb +101 -39
  35. data/lib/eco/api/common/people/supervisor_helpers.rb +25 -26
  36. data/lib/eco/api/common/session/base_session.rb +9 -9
  37. data/lib/eco/api/common/session/environment.rb +7 -5
  38. data/lib/eco/api/common/session/sftp.rb +59 -32
  39. data/lib/eco/api/common/version_patches/ecoportal_api/external_person.rb +10 -6
  40. data/lib/eco/api/common/version_patches/exception.rb +11 -13
  41. data/lib/eco/api/error.rb +32 -20
  42. data/lib/eco/api/microcases/set_supervisor.rb +0 -3
  43. data/lib/eco/api/organization/node_classifications.rb +82 -0
  44. data/lib/eco/api/organization/policy_groups.rb +4 -6
  45. data/lib/eco/api/organization/tag_tree.rb +169 -93
  46. data/lib/eco/api/organization.rb +1 -0
  47. data/lib/eco/api/session/batch/job.rb +1 -1
  48. data/lib/eco/api/session/config/tagtree.rb +41 -23
  49. data/lib/eco/api/session/config/workflow.rb +113 -88
  50. data/lib/eco/api/session/config.rb +6 -0
  51. data/lib/eco/api/session.rb +51 -29
  52. data/lib/eco/api/usecases/base_io.rb +28 -25
  53. data/lib/eco/api/usecases/default/locations/cli/tagtree_extract_cli.rb +7 -2
  54. data/lib/eco/api/usecases/default/locations/cli/tagtree_upload_cli.rb +21 -0
  55. data/lib/eco/api/usecases/default/locations/csv_to_tree_case.rb +3 -3
  56. data/lib/eco/api/usecases/default/locations/tagtree_extract_case.rb +54 -23
  57. data/lib/eco/api/usecases/default/locations/tagtree_upload_case.rb +87 -0
  58. data/lib/eco/api/usecases/default/locations.rb +1 -0
  59. data/lib/eco/api/usecases/default/people/analyse_people_case.rb +60 -56
  60. data/lib/eco/api/usecases/default/people/change_email_case.rb +8 -9
  61. data/lib/eco/api/usecases/default/people/clean_unknown_tags_case.rb +13 -11
  62. data/lib/eco/api/usecases/default/people/clear_abilities_case.rb +2 -2
  63. data/lib/eco/api/usecases/default/people/org_data_convert_case.rb +25 -27
  64. data/lib/eco/api/usecases/default/people/refresh_case.rb +2 -2
  65. data/lib/eco/api/usecases/default/people/reinvite_trans_case.rb +1 -1
  66. data/lib/eco/api/usecases/default/people/reinvite_trans_cli.rb +0 -1
  67. data/lib/eco/api/usecases/default/people/restore_db_case.rb +39 -34
  68. data/lib/eco/api/usecases/default/people/set_default_tag_case.rb +19 -15
  69. data/lib/eco/api/usecases/default/people/supers_cyclic_identify_case.rb +16 -12
  70. data/lib/eco/api/usecases/default_cases/hris_case.rb +17 -15
  71. data/lib/eco/api/usecases/default_cases/samples/sftp_case.rb +30 -16
  72. data/lib/eco/api/usecases/default_cases/to_csv_detailed_case.rb +0 -2
  73. data/lib/eco/api/usecases/graphql/base.rb +5 -3
  74. data/lib/eco/api/usecases/graphql/helpers/base/case_env.rb +4 -1
  75. data/lib/eco/api/usecases/graphql/helpers/base/graphql_env.rb +14 -0
  76. data/lib/eco/api/usecases/graphql/helpers/base.rb +5 -4
  77. data/lib/eco/api/usecases/graphql/helpers/location/base/classifications_parser.rb +60 -0
  78. data/lib/eco/api/usecases/graphql/helpers/location/base/tree_tracking.rb +72 -0
  79. data/lib/eco/api/usecases/graphql/helpers/location/base.rb +25 -59
  80. data/lib/eco/api/usecases/graphql/helpers/location/command/diff/as_update.rb +59 -0
  81. data/lib/eco/api/usecases/graphql/helpers/location/command/diff/compare.rb +49 -0
  82. data/lib/eco/api/usecases/graphql/helpers/location/command/diff.rb +11 -0
  83. data/lib/eco/api/usecases/graphql/helpers/location/command/diffs/stages/commandable.rb +46 -0
  84. data/lib/eco/api/usecases/graphql/helpers/location/command/diffs/stages/diff_sortable/for_archive.rb +23 -0
  85. data/lib/eco/api/usecases/graphql/helpers/location/command/diffs/stages/diff_sortable/for_unarchive.rb +65 -0
  86. data/lib/eco/api/usecases/graphql/helpers/location/command/diffs/stages/diff_sortable.rb +49 -0
  87. data/lib/eco/api/usecases/graphql/helpers/location/command/diffs/stages/sortable/relation_safe_sort.rb +119 -0
  88. data/lib/eco/api/usecases/graphql/helpers/location/command/diffs/stages/sortable.rb +59 -0
  89. data/lib/eco/api/usecases/graphql/helpers/location/command/diffs/stages.rb +82 -0
  90. data/lib/eco/api/usecases/graphql/helpers/location/command/diffs.rb +20 -0
  91. data/lib/eco/api/usecases/graphql/helpers/location/command/optimizations.rb +84 -0
  92. data/lib/eco/api/usecases/graphql/helpers/location/command/result.rb +4 -4
  93. data/lib/eco/api/usecases/graphql/helpers/location/command/results.rb +24 -12
  94. data/lib/eco/api/usecases/graphql/helpers/location/command.rb +21 -24
  95. data/lib/eco/api/usecases/graphql/helpers/location/tags_remap/tags_map.rb +1 -1
  96. data/lib/eco/api/usecases/graphql/helpers/location/tags_remap/tags_set.rb +10 -11
  97. data/lib/eco/api/usecases/graphql/helpers/location/tags_remap.rb +8 -9
  98. data/lib/eco/api/usecases/graphql/samples/location/command/dsl.rb +41 -12
  99. data/lib/eco/api/usecases/graphql/samples/location/command/results.rb +11 -80
  100. data/lib/eco/api/usecases/graphql/samples/location/command/service/tree_update.rb +89 -0
  101. data/lib/eco/api/usecases/graphql/samples/location/command/service.rb +6 -0
  102. data/lib/eco/api/usecases/graphql/samples/location/command/track_changed_ids.rb +89 -0
  103. data/lib/eco/api/usecases/graphql/samples/location/command.rb +3 -0
  104. data/lib/eco/api/usecases/graphql/samples/location/service/base.rb +9 -0
  105. data/lib/eco/api/usecases/graphql/samples/location/service/tree_diff/convertible/heading.rb +18 -0
  106. data/lib/eco/api/usecases/graphql/samples/location/service/tree_diff/convertible/inputable.rb +53 -0
  107. data/lib/eco/api/usecases/graphql/samples/location/service/tree_diff/convertible/parsing/classifications.rb +34 -0
  108. data/lib/eco/api/usecases/graphql/samples/location/service/tree_diff/convertible/parsing/helpers.rb +28 -0
  109. data/lib/eco/api/usecases/graphql/samples/location/service/tree_diff/convertible/parsing.rb +46 -0
  110. data/lib/eco/api/usecases/graphql/samples/location/service/tree_diff/convertible.rb +38 -0
  111. data/lib/eco/api/usecases/graphql/samples/location/service/tree_diff.rb +105 -0
  112. data/lib/eco/api/usecases/graphql/samples/location/service/tree_to_list/converter/discarded.rb +16 -0
  113. data/lib/eco/api/usecases/graphql/samples/location/service/tree_to_list/converter/input.rb +15 -0
  114. data/lib/eco/api/usecases/graphql/samples/location/service/tree_to_list/converter/node_attr_maps.rb +22 -0
  115. data/lib/eco/api/usecases/graphql/samples/location/service/tree_to_list/converter/parser.rb +45 -0
  116. data/lib/eco/api/usecases/graphql/samples/location/service/tree_to_list/converter.rb +36 -0
  117. data/lib/eco/api/usecases/graphql/samples/location/service/tree_to_list/output.rb +56 -0
  118. data/lib/eco/api/usecases/graphql/samples/location/service/tree_to_list.rb +41 -0
  119. data/lib/eco/api/usecases/graphql/samples/location/service.rb +8 -0
  120. data/lib/eco/api/usecases/graphql/samples/location.rb +1 -0
  121. data/lib/eco/api/usecases/graphql/utils/sftp.rb +96 -36
  122. data/lib/eco/api/usecases/ooze_cases/export_register_case.rb +8 -6
  123. data/lib/eco/api/usecases/ooze_samples/helpers/creatable.rb +4 -3
  124. data/lib/eco/api/usecases/ooze_samples/helpers/exportable_ooze.rb +39 -25
  125. data/lib/eco/api/usecases/ooze_samples/helpers/exportable_register.rb +13 -15
  126. data/lib/eco/api/usecases/ooze_samples/helpers/filters.rb +50 -21
  127. data/lib/eco/api/usecases/ooze_samples/helpers/ooze_handlers.rb +21 -11
  128. data/lib/eco/api/usecases/ooze_samples/helpers/rescuable.rb +2 -0
  129. data/lib/eco/api/usecases/ooze_samples/helpers/shortcuts.rb +49 -43
  130. data/lib/eco/api/usecases/ooze_samples/ooze_base_case.rb +17 -19
  131. data/lib/eco/api/usecases/ooze_samples/register_export_case.rb +48 -43
  132. data/lib/eco/api/usecases/ooze_samples/register_update_case.rb +34 -34
  133. data/lib/eco/api/usecases/ooze_samples/target_oozes_update_case.rb +8 -10
  134. data/lib/eco/api/usecases.rb +0 -1
  135. data/lib/eco/cli/config/use_cases.rb +31 -29
  136. data/lib/eco/cli_default/input_filters.rb +0 -5
  137. data/lib/eco/cli_default/people_filters.rb +4 -4
  138. data/lib/eco/cli_default/workflow.rb +13 -14
  139. data/lib/eco/csv/table.rb +34 -25
  140. data/lib/eco/data/hashes/array_diff.rb +24 -35
  141. data/lib/eco/data/hashes/diff_result/meta.rb +131 -0
  142. data/lib/eco/data/hashes/diff_result.rb +65 -57
  143. data/lib/eco/data/hashes/sanke_camel_indifferent_access.rb +278 -0
  144. data/lib/eco/data/hashes.rb +1 -1
  145. data/lib/eco/data/locations/convert.rb +1 -1
  146. data/lib/eco/data/locations/node_base/csv_convert.rb +19 -9
  147. data/lib/eco/data/locations/node_base/parsing.rb +4 -2
  148. data/lib/eco/data/locations/node_base/treeify.rb +149 -132
  149. data/lib/eco/data/locations/node_base.rb +15 -4
  150. data/lib/eco/data/locations/node_diff/accessors.rb +13 -5
  151. data/lib/eco/data/locations/node_diff/nodes_diff/clustered_treeify.rb +101 -0
  152. data/lib/eco/data/locations/node_diff/nodes_diff/diffs_tree.rb +99 -0
  153. data/lib/eco/data/locations/node_diff/{selectors.rb → nodes_diff/selectors.rb} +1 -1
  154. data/lib/eco/data/locations/node_diff/nodes_diff.rb +50 -35
  155. data/lib/eco/data/locations/node_diff.rb +45 -17
  156. data/lib/eco/data/locations/node_level/parsing.rb +15 -21
  157. data/lib/eco/data/locations/node_level.rb +66 -22
  158. data/lib/eco/data/locations/node_plain/parsing.rb +1 -1
  159. data/lib/eco/data/locations/node_plain.rb +60 -7
  160. data/lib/eco/data/strings/camel_case.rb +35 -0
  161. data/lib/eco/data/strings/snake_case.rb +18 -0
  162. data/lib/eco/data/strings.rb +8 -0
  163. data/lib/eco/data.rb +1 -0
  164. data/lib/eco/language/methods/call_detector.rb +11 -0
  165. data/lib/eco/language/methods/dsl_able.rb +7 -1
  166. data/lib/eco/language/methods.rb +2 -1
  167. data/lib/eco/language/models/collection.rb +23 -25
  168. data/lib/eco/language/models/parser_serializer.rb +24 -5
  169. data/lib/eco/version.rb +1 -1
  170. data/lib/eco-helpers.rb +0 -1
  171. metadata +54 -9
  172. data/lib/eco/data/hashes/diff_meta.rb +0 -52
@@ -1,16 +1,14 @@
1
1
  class ::Exception
2
2
  def patch_full_message(trace_count: -1)
3
- begin
4
- msg = []
5
- tracing = backtrace ? backtrace : []
6
- tracing = (self.class == SystemStackError) ? tracing[1..30] : tracing[1..trace_count]
7
- tracing ||= []
8
- msg << "\n#{tracing.first} \n#{message} (#{self.class.to_s})"
9
- tracing.each_with_index {|bt, i| msg << "#{" "*8}#{i+1}: from #{bt}"}
10
- msg.join("\n")
11
- rescue Exception => e
12
- puts "Something is wrong with 'patch_full_message': #{e}"
13
- end
3
+ msg = []
4
+ tracing = backtrace || []
5
+ tracing = instance_of?(SystemStackError) ? tracing[1..30] : tracing[1..trace_count]
6
+ tracing ||= []
7
+ msg << "\n#{tracing.first} \n#{message} (#{self.class})"
8
+ tracing.each_with_index {|bt, i| msg << "#{" "*8}#{i+1}: from #{bt}"}
9
+ msg.join("\n")
10
+ rescue StandardError => e
11
+ puts "Something is wrong with 'patch_full_message': #{e}"
14
12
  end
15
13
  end
16
14
 
@@ -23,7 +21,7 @@ Exception.class_eval do
23
21
  String(message) + super()
24
22
  end
25
23
  end
26
- self.extend mod
24
+ extend mod
27
25
  end
28
26
 
29
27
  def append_message(message)
@@ -32,6 +30,6 @@ Exception.class_eval do
32
30
  super() + String(message)
33
31
  end
34
32
  end
35
- self.extend mod
33
+ extend mod
36
34
  end
37
35
  end
data/lib/eco/api/error.rb CHANGED
@@ -10,56 +10,65 @@ module Eco
10
10
  end
11
11
 
12
12
  @str_err = "api error on the server reply"
13
- @match = /.*/
13
+ @match = /.*/
14
14
  #RxValidId = /[a-f0-9]{24}/
15
15
 
16
-
17
16
  class Unclassified < Eco::API::Error
18
17
  @str_error = "Unclassified error message"
19
18
  @match = /.*/
20
19
  end
21
20
 
22
21
  class InternalServerError < Eco::API::Error
23
- @str_err = "Internal Server Error"
22
+ @str_err = "Internal Server Error"
24
23
  @match = /#{@str_err}/
25
24
  end
25
+
26
26
  class UnknownPersonId < Eco::API::Error
27
27
  @str_err = "Unknown person id"
28
28
  @match = /Cannot find person with id (.*)/
29
29
  end
30
+
30
31
  class ExternalIdTaken < Eco::API::Error
31
- @str_err = "external ID already taken"
32
+ @str_err = "external ID already taken"
32
33
  @match = /#{@str_err}/
33
34
  end
35
+
34
36
  class EmailMissing < Eco::API::Error
35
37
  @str_err = "missing email for account creation"
36
38
  @match = /#{@str_err}/
37
39
  end
40
+
38
41
  class EmailInvalid < Eco::API::Error
39
42
  @str_err = "Email is invalid"
40
43
  @match = /#{@str_err}/
41
44
  end
45
+
42
46
  class EmailTaken < Eco::API::Error
43
- @str_err = "user email already taken"
44
- @str_err2 = "Email is already taken"
45
- @match = /(?:#{@str_err}|#{@str_err2})/
47
+ @str_err = "user email already taken"
48
+ @str_err_2 = "Email is already taken"
49
+ @match = /(?:#{@str_err}|#{@str_err_2})/
46
50
  end
51
+
47
52
  class SupervisorNotFound < Eco::API::Error
48
53
  @str_err = "Supervisor not found"
49
54
  @match = /Supervisor (.*?) not found/
50
55
  end
56
+
51
57
  class CyclicSupervisor < Eco::API::Error
52
58
  @str_err = "Supervisor is cyclic!"
53
59
  @match = /#{@str_err}/
54
60
  end
61
+
55
62
  class SchemaNotFound < Eco::API::Error
56
63
  @str_err = "Schema not found"
57
64
  @match = /Schema (.*?) not found/
58
65
  end
66
+
59
67
  class InvalidObjectId < Eco::API::Error
60
68
  @str_err = "Invalid ObjectId."
61
69
  @match = /'(.*?)' is an invalid ObjectId./
62
70
  end
71
+
63
72
  class UnknownField < Eco::API::Error
64
73
  @str_err = "Unknown field."
65
74
  @match = /(.+?) is an unknown field/
@@ -68,13 +77,15 @@ module Eco
68
77
  @str_err = "Unknown core field."
69
78
  @match = /(.+?) is an unknown field/
70
79
  end
80
+
71
81
  class UnknownAccountField < UnknownField
72
82
  @str_err = "Unknown account field."
73
- @match = /account \> (.+?) is an unknown field/
83
+ @match = /account > (.+?) is an unknown field/
74
84
  end
85
+
75
86
  class UnknownDetailsField < UnknownField
76
87
  @str_err = "Unknown details field."
77
- @match = /details \> (.+?) is an unknown field/
88
+ @match = /details > (.+?) is an unknown field/
78
89
  end
79
90
  end
80
91
 
@@ -82,9 +93,9 @@ module Eco
82
93
  def descendants(direct: false)
83
94
  ObjectSpace.each_object(::Class).select do |klass|
84
95
  klass < self
85
- end.sort do |k1, k2|
86
- next -1 if k2 < k1
87
- next 1 if k1 < k2
96
+ end.sort do |k_1, k_2|
97
+ next -1 if k_2 < k_1
98
+ next 1 if k_1 < k_2
88
99
  0
89
100
  end.tap do |siblings|
90
101
  siblings.delete(Unclassified)
@@ -97,7 +108,7 @@ module Eco
97
108
  end
98
109
 
99
110
  def descendants?(direct: false)
100
- descendants(direct: direct).length > 0
111
+ descendants(direct: direct).length.positive?
101
112
  end
102
113
 
103
114
  def err_match?(err_msg)
@@ -106,15 +117,16 @@ module Eco
106
117
 
107
118
  def get_type(err_msg, first: true)
108
119
  type = nil
120
+
109
121
  descendants(direct: true).reverse.each do |klass|
110
- if klass.err_match?(err_msg)
111
- type = klass
112
- if klass.descendants?(direct: true)
113
- type = klass.get_type(err_msg, first: false) || type
114
- end
115
- end
122
+ next unless klass.err_match?(err_msg)
123
+ type = klass
124
+ next unless klass.descendants?(direct: true)
125
+ type = klass.get_type(err_msg, first: false) || type
116
126
  end
127
+
117
128
  return type unless first
129
+
118
130
  type || Unclassified
119
131
  end
120
132
 
@@ -138,7 +150,7 @@ module Eco
138
150
  end
139
151
 
140
152
  def built_error
141
- str ||= msg
153
+ msg
142
154
  end
143
155
  end
144
156
  end
@@ -38,17 +38,14 @@ module Eco
38
38
  def descrease_subordinates(person, by = 1)
39
39
  if person.is_a?(Ecoportal::API::V1::Person)
40
40
  person.subordinates -= by
41
- #person.subordinates = 0 if person.subordinates < 0
42
41
  end
43
42
  end
44
43
 
45
44
  def increase_subordinates(person, by = 1)
46
45
  if person.is_a?(Ecoportal::API::V1::Person)
47
- #person.subordinates = 0 if person.subordinates < 0
48
46
  person.subordinates += by
49
47
  end
50
48
  end
51
-
52
49
  end
53
50
  end
54
51
  end
@@ -0,0 +1,82 @@
1
+ module Eco
2
+ module API
3
+ module Organization
4
+ class NodeClassifications < Eco::Language::Models::Collection
5
+ # build the shortcuts of Collection
6
+ attr_collection :id, :name # , :active
7
+
8
+ def initialize(types = [], klass: Ecoportal::API::GraphQL::Base::LocationClassificationType) # rubocop:disable Lint/UnusedMethodArgument
9
+ @klass = Ecoportal::API::GraphQL::Base::LocationClassificationType
10
+ @caches_init = false
11
+ super(types, klass: @klass)
12
+ init_caches
13
+ end
14
+
15
+ def ids
16
+ @items.map(&:id)
17
+ end
18
+
19
+ def names
20
+ @items.map(&:name)
21
+ end
22
+
23
+ def to_id(name)
24
+ case name
25
+ when Enumerable
26
+ name.map do |n|
27
+ type(n)&.id
28
+ end.compact
29
+ else
30
+ type(name)&.id
31
+ end
32
+ end
33
+
34
+ def to_name(id)
35
+ case id
36
+ when Enumerable
37
+ id.map do |n|
38
+ type(n)&.name
39
+ end.compact
40
+ else
41
+ type(id)&.name
42
+ end
43
+ end
44
+
45
+ def type(id_name)
46
+ self[id_name]
47
+ end
48
+
49
+ def [](id_name)
50
+ @by_id[type_id(id_name)]
51
+ end
52
+
53
+ private
54
+
55
+ def type_name(id_name)
56
+ key = treat_classication(id_name)
57
+ val = (@by_id[key] || @by_name[key])&.name
58
+ treat_classication(val)
59
+ end
60
+
61
+ def type_id(id_name)
62
+ key = treat_classication(id_name)
63
+ val = (@by_name[key] || @by_id[key])&.id
64
+ treat_classication(val)
65
+ end
66
+
67
+ def treat_classication(value)
68
+ return value unless value.is_a?(String)
69
+ value.strip.gsub(/\W+/, '').downcase
70
+ end
71
+
72
+ def init_caches
73
+ return if @caches_init
74
+
75
+ @by_id = @items.to_h { |nc| [treat_classication(nc.id), nc] }
76
+ @by_name = @items.to_h { |nc| [treat_classication(nc.name), nc] }
77
+ @caches_init = true
78
+ end
79
+ end
80
+ end
81
+ end
82
+ end
@@ -1,7 +1,7 @@
1
1
  module Eco
2
2
  module API
3
3
  module Organization
4
- class PolicyGroups < Eco::Language::Models::Collection
4
+ class PolicyGroups < Eco::Language::Models::Collection
5
5
  # build the shortcuts of Collection
6
6
  attr_collection :id, :name
7
7
 
@@ -40,7 +40,6 @@ module Eco
40
40
  else
41
41
  policy_group(id)&.name
42
42
  end
43
-
44
43
  end
45
44
 
46
45
  def policy_group(id_name)
@@ -61,7 +60,7 @@ module Eco
61
60
 
62
61
  if !non_custom_not_used && preserve_custom
63
62
  initial_custom = initial - non_custom
64
- final = final + initial_custom
63
+ final += initial_custom
65
64
  end
66
65
 
67
66
  new_pg_ids = final - initial
@@ -81,11 +80,10 @@ module Eco
81
80
 
82
81
  def init_caches
83
82
  return if @caches_init
84
- @by_id = self.map { |pg| [pg.id, pg] }.to_h
85
- @by_name = self.map { |pg| [pg.name&.downcase, pg] }.to_h
83
+ @by_id = map { |pg| [pg.id, pg] }.to_h
84
+ @by_name = map { |pg| [pg.name&.downcase, pg] }.to_h
86
85
  @caches_init = true
87
86
  end
88
-
89
87
  end
90
88
  end
91
89
  end