eco-helpers 3.0.30 → 3.0.32

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 (35) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +26 -1
  3. data/eco-helpers.gemspec +1 -1
  4. data/lib/eco/api/common/loaders/use_case/cli_identify.rb +3 -0
  5. data/lib/eco/api/common/people/person_entry.rb +2 -0
  6. data/lib/eco/api/microcases/people/fetch/with_each.rb +9 -2
  7. data/lib/eco/api/organization/people/multiple_search_results.rb +42 -36
  8. data/lib/eco/api/organization/people/similarity.rb +226 -224
  9. data/lib/eco/api/organization/people.rb +1 -0
  10. data/lib/eco/api/session/batch/job.rb +1 -0
  11. data/lib/eco/api/usecases/cli/dsl.rb +0 -1
  12. data/lib/eco/api/usecases/cli/option.rb +1 -1
  13. data/lib/eco/api/usecases/default_cases/create_case.rb +3 -3
  14. data/lib/eco/api/usecases/default_cases/delete_sync_case.rb +2 -2
  15. data/lib/eco/api/usecases/default_cases/delete_trans_case.rb +3 -3
  16. data/lib/eco/api/usecases/default_cases/hris_case.rb +10 -9
  17. data/lib/eco/api/usecases/default_cases/to_csv_case.rb +10 -10
  18. data/lib/eco/api/usecases/default_cases/to_csv_detailed_case.rb +50 -50
  19. data/lib/eco/api/usecases/default_cases/update_case.rb +3 -3
  20. data/lib/eco/api/usecases/graphql/samples/location/service/tree_diff/convertible/inputable.rb +4 -1
  21. data/lib/eco/api/usecases/lib/files/sftp.rb +5 -1
  22. data/lib/eco/cli/config/use_cases/active_case.rb +9 -0
  23. data/lib/eco/cli/config/use_cases/case_config.rb +27 -0
  24. data/lib/eco/cli/config/use_cases.rb +2 -15
  25. data/lib/eco/cli_default/usecases.rb +1 -1
  26. data/lib/eco/data/files/helpers.rb +3 -0
  27. data/lib/eco/language/delegation/delegating_blank.rb +4 -16
  28. data/lib/eco/language/delegation/delegating_missing_const.rb +1 -1
  29. data/lib/eco/language/methods/call_detector.rb +4 -8
  30. data/lib/eco/language/methods/dsl_able.rb +29 -33
  31. data/lib/eco/language/methods/instance_method_helpers.rb +38 -0
  32. data/lib/eco/language/methods.rb +1 -0
  33. data/lib/eco/language.rb +1 -1
  34. data/lib/eco/version.rb +1 -1
  35. metadata +7 -4
@@ -1,287 +1,289 @@
1
- module API
2
- module Organization
3
- class People
4
- # Class to find out duplicates in the People Manager
5
- #
6
- # @attr_writer attribute [String, Proc, nil] the target attribute to be read.
7
- class Similarity < Eco::API::Organization::People
8
- include Eco::Data::FuzzyMatch
9
-
10
- # @!group Config
11
- # @return [String, Proc, nil] the target attribute to be read.
12
- attr_writer :attribute
13
-
14
- def attribute
15
- @attribute ||= :name
16
- end
1
+ module Eco
2
+ module API
3
+ module Organization
4
+ class People
5
+ # Class to find out duplicates in the People Manager
6
+ #
7
+ # @attr_writer attribute [String, Proc, nil] the target attribute to be read.
8
+ class Similarity < Eco::API::Organization::People
9
+ include Eco::Data::FuzzyMatch
10
+
11
+ # @!group Config
12
+ # @return [String, Proc, nil] the target attribute to be read.
13
+ attr_writer :attribute
14
+
15
+ def attribute
16
+ @attribute ||= :name
17
+ end
17
18
 
18
- # Returns the target value to analyse
19
- # @param person [Ecoportal::API::V1::Person]
20
- def item_value(item)
21
- return attribute.call(item) if attribute.is_a?(Proc)
19
+ # Returns the target value to analyse
20
+ # @param person [Ecoportal::API::V1::Person]
21
+ def item_value(item)
22
+ return attribute.call(item) if attribute.is_a?(Proc)
22
23
 
23
- attr = attribute.to_sym
24
- item.send(attr) if item.respond_to?(attr)
25
- end
24
+ attr = attribute.to_sym
25
+ item.send(attr) if item.respond_to?(attr)
26
+ end
26
27
 
27
- # Define the order or relevant of per user matches
28
- # @param values[Array<Symbol>] the algorithms' results it should
29
- # be ordered by:
30
- # * Possible values: `:dice`, `:levenshtein`, `:jaro_winkler`,
31
- # `:ngrams`, `:words_ngrams`, `:chars_position`
32
- attr_writer :order
28
+ # Define the order or relevant of per user matches
29
+ # @param values[Array<Symbol>] the algorithms' results it should
30
+ # be ordered by:
31
+ # * Possible values: `:dice`, `:levenshtein`, `:jaro_winkler`,
32
+ # `:ngrams`, `:words_ngrams`, `:chars_position`
33
+ attr_writer :order
33
34
 
34
- def order
35
- @order ||= %i[words_ngrams dice]
36
- end
35
+ def order
36
+ @order ||= %i[words_ngrams dice]
37
+ end
37
38
 
38
- # Define the order or relevant of per user matches
39
- # @param value [Float] the threshold that all of the algorithms should comply with
40
- attr_writer :threshold
39
+ # Define the order or relevant of per user matches
40
+ # @param value [Float] the threshold that all of the algorithms should comply with
41
+ attr_writer :threshold
41
42
 
42
- def threshold
43
- @threshold ||= 0.15
44
- end
43
+ def threshold
44
+ @threshold ||= 0.15
45
+ end
45
46
 
46
- # Generates a new object with same config but different base `data`.
47
- # @return [Eco::API::Organization::People::Similarity]
48
- def newFrom(data) # rubocop:disable Naming/MethodName
49
- super(data).tap do |simil|
50
- simil.threshold = threshold
51
- simil.order = order
52
- simil.attribute = attribute
47
+ # Generates a new object with same config but different base `data`.
48
+ # @return [Eco::API::Organization::People::Similarity]
49
+ def newFrom(data) # rubocop:disable Naming/MethodName
50
+ super(data).tap do |simil|
51
+ simil.threshold = threshold
52
+ simil.order = order
53
+ simil.attribute = attribute
54
+ end
53
55
  end
54
- end
55
56
 
56
- # @!endgroup
57
+ # @!endgroup
57
58
 
58
- # @!group Searchers
59
+ # @!group Searchers
59
60
 
60
- # It gathers those that have the same `email`
61
- # @return [Hash] where `keys` are `email`s and `values` an `Array<Person>`
62
- def repeated_emails
63
- init_caches
64
- @by_email.select do |_email, people|
65
- people.count > 1
61
+ # It gathers those that have the same `email`
62
+ # @return [Hash] where `keys` are `email`s and `values` an `Array<Person>`
63
+ def repeated_emails
64
+ init_caches
65
+ @by_email.select do |_email, people|
66
+ people.count > 1
67
+ end
66
68
  end
67
- end
68
69
 
69
- # It returns all people with no name
70
- # @return [Eco::API::Organization::People::Similarity]
71
- def unnamed
72
- select do |person|
73
- person.name.to_s.strip.length < 2
74
- end.then do |results|
75
- newFrom(results)
70
+ # It returns all people with no name
71
+ # @return [Eco::API::Organization::People::Similarity]
72
+ def unnamed
73
+ select do |person|
74
+ person.name.to_s.strip.length < 2
75
+ end.then do |results|
76
+ newFrom(results)
77
+ end
76
78
  end
77
- end
78
79
 
79
- # It returns all people with no name
80
- # @return [Eco::API::Organization::People::Similarity]
81
- def named
82
- reject do |person|
83
- person.name.to_s.strip.length < 2
84
- end.then do |results|
85
- newFrom(results)
80
+ # It returns all people with no name
81
+ # @return [Eco::API::Organization::People::Similarity]
82
+ def named
83
+ reject do |person|
84
+ person.name.to_s.strip.length < 2
85
+ end.then do |results|
86
+ newFrom(results)
87
+ end
86
88
  end
87
- end
88
89
 
89
- # It returns all the entries with `attribute` empty
90
- # @return [Eco::API::Organization::People::Similarity]
91
- def blank_attribute
92
- select do |person|
93
- item_value(person).to_s.strip.length < 2
94
- end.then do |results|
95
- newFrom(results)
90
+ # It returns all the entries with `attribute` empty
91
+ # @return [Eco::API::Organization::People::Similarity]
92
+ def blank_attribute
93
+ select do |person|
94
+ item_value(person).to_s.strip.length < 2
95
+ end.then do |results|
96
+ newFrom(results)
97
+ end
96
98
  end
97
- end
98
99
 
99
- # It returns all the entries with `attribute` **n0t** empty
100
- # @return [Eco::API::Organization::People::Similarity]
101
- def attribute_present
102
- reject do |person|
103
- item_value(person).to_s.strip.length < 2
104
- end.then do |results|
105
- newFrom(results)
100
+ # It returns all the entries with `attribute` **n0t** empty
101
+ # @return [Eco::API::Organization::People::Similarity]
102
+ def attribute_present
103
+ reject do |person|
104
+ item_value(person).to_s.strip.length < 2
105
+ end.then do |results|
106
+ newFrom(results)
107
+ end
106
108
  end
107
- end
108
109
 
109
- # @!endgroup
110
-
111
- # @!group Analisys starters
112
-
113
- # Analyses People bases on `options`
114
- # @param needle_read [Proc, Symbol] when the value to
115
- # read from `needle` object is different to the `:read` (`attribute`).
116
- # This allows to for example, facet `needle.name` (needle_read)
117
- # against `haystack_item.details[alt_id]` (read).
118
- # @param keep_empty [Boolean] to indicate if it should get
119
- # rid of people with no results (based on threshold)
120
- # @return [Hash] where the _keys_ are the people `id`s and
121
- # the _values_ the `Eco::Data::FuzzyMatch::Results`
122
- def analyse(needle_read: nil, keep_empty: false, **options)
123
- options = { read: attribute }.merge(options)
124
- total = count
125
- i = 1
126
-
127
- each_with_object({}) do |person, results|
128
- needle_str = needle_read ? item_string(person, needle_read) : nil
129
- results[person.id] = find_all_with_score(person, needle_str: needle_str, **options)
130
-
131
- print_progress('Analysed', total, i)
132
- i += 1
133
- end.then do |analysed|
134
- analysed = clean_empty(analysed) unless keep_empty
135
- #puts "... #{analysed.count} results after cleaning empty"
136
- analysed
110
+ # @!endgroup
111
+
112
+ # @!group Analisys starters
113
+
114
+ # Analyses People bases on `options`
115
+ # @param needle_read [Proc, Symbol] when the value to
116
+ # read from `needle` object is different to the `:read` (`attribute`).
117
+ # This allows to for example, facet `needle.name` (needle_read)
118
+ # against `haystack_item.details[alt_id]` (read).
119
+ # @param keep_empty [Boolean] to indicate if it should get
120
+ # rid of people with no results (based on threshold)
121
+ # @return [Hash] where the _keys_ are the people `id`s and
122
+ # the _values_ the `Eco::Data::FuzzyMatch::Results`
123
+ def analyse(needle_read: nil, keep_empty: false, **options)
124
+ options = { read: attribute }.merge(options)
125
+ total = count
126
+ i = 1
127
+
128
+ each_with_object({}) do |person, results|
129
+ needle_str = needle_read ? item_string(person, needle_read) : nil
130
+ results[person.id] = find_all_with_score(person, needle_str: needle_str, **options)
131
+
132
+ print_progress('Analysed', total, i)
133
+ i += 1
134
+ end.then do |analysed|
135
+ analysed = clean_empty(analysed) unless keep_empty
136
+ #puts "... #{analysed.count} results after cleaning empty"
137
+ analysed
138
+ end
137
139
  end
138
- end
139
140
 
140
- # @!endgroup
141
+ # @!endgroup
141
142
 
142
- # @!group Results Treatment
143
+ # @!group Results Treatment
143
144
 
144
- # Gets a new instance object of this class, with only people in results
145
- # @param analysed [Hash] where the _keys_ are the people `id`s and _values_ the `Eco::Data::FuzzyMatch::Results`
146
- # @return [Eco::API::Organization::People::Similarity]
147
- def newSimilarity(analysed) # rubocop:disable Naming/MethodName
148
- newFrom(people_in_results(analysed))
149
- end
145
+ # Gets a new instance object of this class, with only people in results
146
+ # @param analysed [Hash] where the _keys_ are the people `id`s and _values_ the `Eco::Data::FuzzyMatch::Results`
147
+ # @return [Eco::API::Organization::People::Similarity]
148
+ def newSimilarity(analysed) # rubocop:disable Naming/MethodName
149
+ newFrom(people_in_results(analysed))
150
+ end
150
151
 
151
- def people_in_results(analysed)
152
- analysed.each_with_object([]) do |(id, results), people|
153
- # spot related
154
- results.each_with_object([self[id]]) do |result, related|
155
- related << result.match
156
- end.each do |person|
157
- next if people.include?(person)
152
+ def people_in_results(analysed)
153
+ analysed.each_with_object([]) do |(id, results), people|
154
+ # spot related
155
+ results.each_with_object([self[id]]) do |result, related|
156
+ related << result.match
157
+ end.each do |person|
158
+ next if people.include?(person)
158
159
 
159
- people << person
160
+ people << person
161
+ end
160
162
  end
161
163
  end
162
- end
163
164
 
164
- # Removes from results those that do not have similar entries
165
- def clean_empty(analysed)
166
- analysed.reject do |_id, results|
167
- results.empty?
165
+ # Removes from results those that do not have similar entries
166
+ def clean_empty(analysed)
167
+ analysed.reject do |_id, results|
168
+ results.empty?
169
+ end
168
170
  end
169
- end
170
171
 
171
- # Helper to do some treatment fo the results
172
- # @param analysed [Hash] where the _keys_ are the people `id`s and _values_ the `Eco::Data::FuzzyMatch::Results`
173
- # @return [Hash] where the _keys_ are the people `id`s and _values_ the `Eco::Data::FuzzyMatch::Results`
174
- def with_analysed(analysed, keep_empty: false)
175
- analysed.each_with_object({}) do |(id, results), reanalysed|
176
- reanalysed[id] = yield(self[id], results)
177
- end.then do |reanalysed|
178
- reanalysed = clean_empty(reanalysed) unless keep_empty
179
- reanalysed
180
- end.tap do |out|
181
- puts "with_analysed... returns #{out.count} records"
172
+ # Helper to do some treatment fo the results
173
+ # @param analysed [Hash] where the _keys_ are the people `id`s and _values_ the `Eco::Data::FuzzyMatch::Results`
174
+ # @return [Hash] where the _keys_ are the people `id`s and _values_ the `Eco::Data::FuzzyMatch::Results`
175
+ def with_analysed(analysed, keep_empty: false)
176
+ analysed.each_with_object({}) do |(id, results), reanalysed|
177
+ reanalysed[id] = yield(self[id], results)
178
+ end.then do |reanalysed|
179
+ reanalysed = clean_empty(reanalysed) unless keep_empty
180
+ reanalysed
181
+ end.tap do |out|
182
+ puts "with_analysed... returns #{out.count} records"
183
+ end
182
184
  end
183
- end
184
185
 
185
- # Launches a reanalyis on `analysed` based on `options`
186
- # @param analysed [Hash] where the _keys_ are the people `id`s and the _values_ the `Eco::Data::FuzzyMatch::Results`
187
- def rearrange(analysed, **options)
188
- with_analysed(analysed) do |person, results|
189
- results.relevant_results(**options)
186
+ # Launches a reanalyis on `analysed` based on `options`
187
+ # @param analysed [Hash] where the _keys_ are the people `id`s and the _values_ the `Eco::Data::FuzzyMatch::Results`
188
+ def rearrange(analysed, **options)
189
+ with_analysed(analysed) do |person, results|
190
+ results.relevant_results(**options)
191
+ end
190
192
  end
191
- end
192
193
 
193
- # Reanalyses by using a block to treat the needle and item values
194
- def reanalyse(analysed, msg: 'Reanalysing', **options, &block)
195
- options = { read: attribute }.merge(options)
196
- total = analysed.count
197
- i = 1
194
+ # Reanalyses by using a block to treat the needle and item values
195
+ def reanalyse(analysed, msg: 'Reanalysing', **options, &block)
196
+ options = { read: attribute }.merge(options)
197
+ total = analysed.count
198
+ i = 1
198
199
 
199
- with_analysed(analysed) do |_person, results|
200
- print_progress(msg, total, i)
201
- i += 1
202
- recalculate_results(results, &block)
200
+ with_analysed(analysed) do |_person, results|
201
+ print_progress(msg, total, i)
202
+ i += 1
203
+ recalculate_results(results, &block)
204
+ end
203
205
  end
204
- end
205
206
 
206
- # Renalyses by ignoring matching words between the `needle` and those found in `results`
207
- def ignore_matching_words(analysed, **options)
208
- prompt = 'Reanalysing by ignoring matching words'
207
+ # Renalyses by ignoring matching words between the `needle` and those found in `results`
208
+ def ignore_matching_words(analysed, **options)
209
+ prompt = 'Reanalysing by ignoring matching words'
209
210
 
210
- reanalyse(analysed, msg: prompt, **options) do |needle_str, item_str, _needle, _item|
211
- self.class.remove_matching_words(needle_str, item_str)
211
+ reanalyse(analysed, msg: prompt, **options) do |needle_str, item_str, _needle, _item|
212
+ self.class.remove_matching_words(needle_str, item_str)
213
+ end
212
214
  end
213
- end
214
215
 
215
- # Renalyses by ignoring matching words between the `needle` and those found in `results`
216
- def ignore_matching_words_old(analysed, **options)
217
- options = { read: attribute }.merge(options)
218
- total = analysed.count
219
- i = 1
216
+ # Renalyses by ignoring matching words between the `needle` and those found in `results`
217
+ def ignore_matching_words_old(analysed, **options)
218
+ options = { read: attribute }.merge(options)
219
+ total = analysed.count
220
+ i = 1
220
221
 
221
- with_analysed(analysed) do |person, results|
222
- print_progress('Reanalysing by ignoring matching words', total, i)
223
- i += 1
224
- ignore_same_words_score(results, **options)
222
+ with_analysed(analysed) do |person, results|
223
+ print_progress('Reanalysing by ignoring matching words', total, i)
224
+ i += 1
225
+ ignore_same_words_score(results, **options)
226
+ end
225
227
  end
226
- end
227
228
 
228
- # @!endgroup
229
+ # @!endgroup
229
230
 
230
- # @!group Reporting Helpers
231
+ # @!group Reporting Helpers
231
232
 
232
- # @return [String] well structured text
233
- def report(analysed, format: :txt)
234
- case format
235
- when :txt
236
- analysed.each_with_object('') do |(id, results), out|
237
- out << "#{self[id].identify}:\n "
238
- out << results.results.map(&:print).join("\n ")
239
- out << "\n"
233
+ # @return [String] well structured text
234
+ def report(analysed, format: :txt)
235
+ case format
236
+ when :txt
237
+ analysed.each_with_object('') do |(id, results), out|
238
+ out << "#{self[id].identify}:\n "
239
+ out << results.results.map(&:print).join("\n ")
240
+ out << "\n"
241
+ end
240
242
  end
241
243
  end
242
- end
243
244
 
244
- # @note
245
- # 1. Unless `:analysed` is provided, it launches an analysis cutting with Jaro Winker min 0.5
246
- # 2. It then re-sorts and cuts based on `options`
247
- # @return [Hash] where the _keys_ are the people `id`s and the _values_ the `Eco::Data::FuzzyMatch::Results`
248
- def print_analysis(**options)
249
- analysed = options[:analysed]
250
- analysed ||= results_with_false_positives.analyse(**options)
245
+ # @note
246
+ # 1. Unless `:analysed` is provided, it launches an analysis cutting with Jaro Winker min 0.5
247
+ # 2. It then re-sorts and cuts based on `options`
248
+ # @return [Hash] where the _keys_ are the people `id`s and the _values_ the `Eco::Data::FuzzyMatch::Results`
249
+ def print_analysis(**options)
250
+ analysed = options[:analysed]
251
+ analysed ||= results_with_false_positives.analyse(**options)
251
252
 
252
- analysed.each_with_object({}) do |(id, results), out|
253
- puts report(analysed)
253
+ analysed.each_with_object({}) do |(id, results), out|
254
+ puts report(analysed)
255
+ end
254
256
  end
255
- end
256
- # @!endgroup
257
+ # @!endgroup
257
258
 
258
- protected
259
+ protected
259
260
 
260
- def on_change
261
- remove_instance_variable(@fuzzy_match)
262
- super
263
- end
261
+ def on_change
262
+ remove_instance_variable(@fuzzy_match)
263
+ super
264
+ end
264
265
 
265
- private
266
+ private
266
267
 
267
- def print_progress(msg, total, num)
268
- return unless total > 10
269
- puts '' unless num > 1
268
+ def print_progress(msg, total, num)
269
+ return unless total > 10
270
+ puts '' unless num > 1
270
271
 
271
- @print_msg_len ||= 0
272
- percent = (100 * num.to_f / total).round(1)
273
- msg = " #{msg}: #{percent}% (#{num} of #{total})\r"
274
- @print_msg_len = msg.length unless @print_msg_len > msg.length
272
+ @print_msg_len ||= 0
273
+ percent = (100 * num.to_f / total).round(1)
274
+ msg = " #{msg}: #{percent}% (#{num} of #{total})\r"
275
+ @print_msg_len = msg.length unless @print_msg_len > msg.length
275
276
 
276
- print msg
277
- $stdout.flush
277
+ print msg
278
+ $stdout.flush
278
279
 
279
- return unless percent > 99.9
280
+ return unless percent > 99.9
280
281
 
281
- sleep(0.2)
282
- print "#{' ' * @print_msg_len}\r"
283
- $stdout.flush
284
- nil
282
+ sleep(0.2)
283
+ print "#{' ' * @print_msg_len}\r"
284
+ $stdout.flush
285
+ nil
286
+ end
285
287
  end
286
288
  end
287
289
  end
@@ -127,6 +127,7 @@ module Eco
127
127
  id = attr_value(object, 'id')
128
128
  external_id = attr_value(object, 'external_id')
129
129
  email = attr_value(object, 'email')
130
+
130
131
  person(id: id, external_id: external_id, email: email, strict: strict)
131
132
  end
132
133
  # @!endgroup
@@ -506,6 +506,7 @@ module Eco
506
506
  dir = config.people.requests_folder
507
507
  filename = name.split(' ').join('-').gsub(/[=\\\/><,"-]+/, '_') # rubocop:disable Style/RedundantArgument
508
508
  file = File.join(dir, "#{type}_data_#{filename}#{dry_run}.json")
509
+
509
510
  file_manager.save_json(requests, file, :timestamp)
510
511
  end
511
512
 
@@ -5,7 +5,6 @@ module Eco
5
5
  module DSL
6
6
  # Links the usecase to the Cli via `arg_case`
7
7
  def apply!(arg_case = cli_name)
8
-
9
8
  # puts "Debug: (#{self}) Tried to call again cli.apply! on '#{arg_case}'"
10
9
  return self if applied?(arg_case)
11
10
 
@@ -10,7 +10,7 @@ class Eco::API::UseCases::Cli
10
10
  end
11
11
 
12
12
  def dup(name: self.name, desc: self.desc, &block)
13
- self.class.new(name, desc, &(block || callback))
13
+ self.class.new(name, desc, &(block || callback)) # rubocop:disable Style/RedundantParentheses
14
14
  end
15
15
 
16
16
  def link_case(cli_config_case)
@@ -1,10 +1,10 @@
1
1
  class Eco::API::UseCases::DefaultCases::CreateCase < Eco::API::Common::Loaders::UseCase
2
- name "create"
2
+ name 'create'
3
3
  type :sync
4
4
 
5
5
  def main(entries, people, session, options, usecase)
6
- creation = session.new_job("main", "create", :create, usecase)
7
- supers = session.new_job("post", "supers", :update, usecase, :core)
6
+ creation = session.new_job('main', 'create', :create, usecase)
7
+ supers = session.new_job('post', 'supers', :update, usecase, :core)
8
8
 
9
9
  micro.with_each_starter(entries, people, options, log_present: true, append_created: append_created) do |entry, person|
10
10
  creation.add(person)
@@ -1,8 +1,8 @@
1
1
  class Eco::API::UseCases::DefaultCases::DeleteSyncCase < Eco::API::UseCases::DefaultCases::DeleteTransCase
2
- name "delete"
2
+ name 'delete'
3
3
  type :sync
4
4
 
5
- def main(entries, people, session, options, usecase)
5
+ def main(entries, *_args)
6
6
  found = micro.with_each_present(entries, people, options, log_starter: true)
7
7
  delete(found)
8
8
  end
@@ -1,13 +1,13 @@
1
1
  class Eco::API::UseCases::DefaultCases::DeleteTransCase < Eco::API::Common::Loaders::UseCase
2
- name "delete"
2
+ name 'delete'
3
3
  type :transform
4
4
 
5
5
  def delete(people)
6
- delete = session.new_job("main", "delete", :delete, usecase)
6
+ delete = session.new_job('main', 'delete', :delete, usecase)
7
7
  people.each {|person| delete.add(person)}
8
8
  end
9
9
 
10
- def main(people, session, options, usecase)
10
+ def main(*_args)
11
11
  delete(people)
12
12
  end
13
13
  end
@@ -1,5 +1,5 @@
1
1
  class Eco::API::UseCases::DefaultCases::HrisCase < Eco::API::Common::Loaders::UseCase
2
- name "hris"
2
+ name 'hris'
3
3
  type :sync
4
4
 
5
5
  attr_reader :creation, :update, :supers, :leavers
@@ -7,10 +7,10 @@ class Eco::API::UseCases::DefaultCases::HrisCase < Eco::API::Common::Loaders::Us
7
7
  def main(entries, people, session, options, usecase)
8
8
  require_only_one_schema!
9
9
  micro = session.micro
10
- @leavers = session.new_job("pre", "leavers", :update, usecase, :account)
11
- @creation = session.new_job("main", "create", :create, usecase)
12
- @update = session.new_job("main", "update", :update, usecase)
13
- @supers = session.new_job("post", "supers", :update, usecase, :core)
10
+ @leavers = session.new_job('pre', 'leavers', :update, usecase, :account)
11
+ @creation = session.new_job('main', 'create', :create, usecase)
12
+ @update = session.new_job('main', 'update', :update, usecase)
13
+ @supers = session.new_job('post', 'supers', :update, usecase, :core)
14
14
 
15
15
  micro.with_each_leaver(entries, people, options) do |person|
16
16
  leavers.add(person, &method(:leavers_callback))
@@ -18,6 +18,7 @@ class Eco::API::UseCases::DefaultCases::HrisCase < Eco::API::Common::Loaders::Us
18
18
 
19
19
  micro.with_each(entries, people, options, append_created: append_created) do |entry, person|
20
20
  person.new? ? creation.add(person) : update.add(person)
21
+
21
22
  micro.set_core_with_supervisor(entry, person, people, supers, options)
22
23
  entry.set_details(person) unless options.dig(:exclude, :details)
23
24
  micro.set_account(entry, person, options)
@@ -45,10 +46,10 @@ class Eco::API::UseCases::DefaultCases::HrisCase < Eco::API::Common::Loaders::Us
45
46
 
46
47
  msg = "There are #{other_people.length} people in schemas other than #{active_schema.name}."
47
48
  msg << " Please, use the filter option '-schema-id SchemaName' for the 'hris' case"
48
- msg << " to only include those of that schema in the current update."
49
- msg << " The HRIS case identifies people that are not in the file as leavers"
50
- msg << " (as it will remove the account of all the people of other schemas"
51
- msg << " if they are not in the input file)."
49
+ msg << ' to only include those of that schema in the current update.'
50
+ msg << ' The HRIS case identifies people that are not in the file as leavers'
51
+ msg << ' (as it will remove the account of all the people of other schemas'
52
+ msg << ' if they are not in the input file).'
52
53
  msg << "\n For example: -schema-id '#{active_schema.name.downcase}'"
53
54
  log(:error) { msg }
54
55
  raise msg