eco-helpers 2.0.24 → 2.0.25

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: a2d943cd8ff8df507a2285548d7bf0c8fffa4009df45de1c26f38e4c966c747f
4
- data.tar.gz: 14cdb53085deec51b406000048aa00199478ef9458290061cb47d324957ec1f2
3
+ metadata.gz: 06a58306abadf9b27421583990eb14960f7f30368515481b16aa474de1bc1b08
4
+ data.tar.gz: 0eef93068fdb31bc6d1949f1022eac325403ac3dbb47c95b593a5b9623655773
5
5
  SHA512:
6
- metadata.gz: 8563f5eaac3f8b650b62138fd31252d990467be498f9620bf7276a430ab8470acf1f2a8ab7b3e6ebcb9accedc1af94ac7168e6acdf3eb94de516259069a49c80
7
- data.tar.gz: 881d6742b555d4b3cf42addef76470b35764684cbca0f903252ae5a39f503dc6a89d9bd7f7f774c587c0b6a23a6f898274af227baf14090d40ae30a16144eecc
6
+ metadata.gz: 80b0d2fc7bedb99deabae6d7d273cb4967eb0022db2e743078a82cace02d4f499fe8ad51ec02b7c5bcef549aac9fb03b0ea7ef5358fb602c65856654c7c20814
7
+ data.tar.gz: 553e1342f38c244ab57bb259b639d55ddc4a4d5d6f72bd54ed9290111636f4dffb29834f69a5b7d2707ee3d44951fa52efccf81589194f11dfa1a709309ddb77
data/CHANGELOG.md CHANGED
@@ -1,13 +1,23 @@
1
1
  # Change Log
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
- ## [2.0.24] - 2021-06-xx
4
+ ## [2.0.25] - 2021-06-xx
5
5
 
6
6
  ### Added
7
- - `Eco::API::Session::Batch::Job` made **native** `-include-excluded`
8
- * also added new option `-include-only-excluded` to be able to only target people HRIS excluded
7
+ - `Eco::API::UseCases::DefaultCases::HrisCase` validation error to require `-schema-id` command line when there are people in schemas other than the active one
8
+
9
9
  ### Changed
10
+ - `Eco::API::Session::Batch::Job`
11
+ * for backwards compatibility `-include-only-excluded` should bring an options structure compatible with `-include-excluded`
12
+
10
13
  ### Fixed
14
+ - `Eco::API::Session::Batch` fixed typo that would prevent `prompt_user` to work
15
+
16
+ ## [2.0.24] - 2021-06-22
17
+
18
+ ### Added
19
+ - `Eco::API::Session::Batch::Job` made **native** `-include-excluded`
20
+ * also added new option `-include-only-excluded` to be able to only target people HRIS excluded
11
21
 
12
22
 
13
23
  ## [2.0.23] - 2021-06-22
@@ -164,7 +164,7 @@ module Eco
164
164
 
165
165
  run = true
166
166
  if Eco::API::Common::Session::FileManager.file_exists?(file)
167
- prompt_user("The file '#{file}' already exists. Do you want to overwrite it? (Y/n):", default: "Y") do |response|
167
+ prompt_user("Do you want to overwrite it? (Y/n):", explanation: "The file '#{file}' already exists.", default: "Y") do |response|
168
168
  run = (response == "") || reponse.upcase.start_with?("Y")
169
169
  end
170
170
  end
@@ -210,6 +210,12 @@ module Eco
210
210
  to_h(:supervisor_id)
211
211
  end
212
212
 
213
+ def group_by_schema
214
+ to_h do |person|
215
+ person.details && person.details.schema_id
216
+ end
217
+ end
218
+
213
219
  def to_h(attr = "id")
214
220
  super(attr || "id")
215
221
  end
@@ -137,7 +137,7 @@ module Eco
137
137
  rescue error_type => e
138
138
  raise unless retries_left > 0
139
139
  explanation = "Batch TimeOut. You have #{retries_left} retries left."
140
- prompt_user("Do you want to retry (y/N)?", explanation, default: "Y", timeout: 10) do |response|
140
+ prompt_user(" Do you want to retry (y/N)?", default: "Y", explanation: explanation, timeout: 10) do |response|
141
141
  if response.upcase.start_with?("Y")
142
142
  offer_retry_on(error_type, retries_left - 1, &block)
143
143
  else
@@ -253,7 +253,7 @@ module Eco
253
253
  def api_included(full_queue)
254
254
  return full_queue if type == :create
255
255
  return full_queue unless excluded = session.config.people.api_excluded
256
- if options.dig(:include, :only_excluded)
256
+ if options.dig(:include, :excluded, :only)
257
257
  full_queue.select {|entry| excluded.call(entry, session, options, self)}
258
258
  elsif options.dig(:include, :excluded)
259
259
  full_queue
@@ -3,8 +3,11 @@ class Eco::API::UseCases::DefaultCases::HrisCase < Eco::API::Common::Loaders::Us
3
3
  type :sync
4
4
 
5
5
  attr_reader :creation, :update, :supers, :leavers
6
+ attr_reader :people, :session, :options
6
7
 
7
8
  def main(entries, people, session, options, usecase)
9
+ @session = session; @options = options; @people = people
10
+ require_only_one_schema!
8
11
  micro = session.micro
9
12
  @creation = session.new_job("main", "create", :create, usecase)
10
13
  @update = session.new_job("main", "update", :update, usecase)
@@ -30,4 +33,21 @@ class Eco::API::UseCases::DefaultCases::HrisCase < Eco::API::Common::Loaders::Us
30
33
  person.account = nil if person.account
31
34
  end
32
35
 
36
+ def require_only_one_schema!
37
+ unless schema_id = options.dig(:people, :filter, :details, :schema_id)
38
+ active_schema = session.schema
39
+ other_schemas = session.schemas.map(&:id) - [active_schema.id]
40
+ other_people = people.group_by_schema.values_at(*other_schemas).map(&:to_a).flatten
41
+ if other_people.length > 3
42
+ msg = "There are #{other_people.length} people in schemas other than #{active_schema.name}."
43
+ msg << " Please, use the filter option '-schema_id SchemaName' for the 'hris' case to only include those of that schema"
44
+ msg << " in the current update. The HRIS case identifies people that are not in the file as leavers."
45
+ msg << " (as it will remove the account of all the people of other schemas if they are not in the input file)."
46
+ msg << "\n For example: -schema-id '#{active_schema.name.downcase}'"
47
+ logger.error(msg)
48
+ raise msg
49
+ end
50
+ end
51
+ end
52
+
33
53
  end
@@ -95,7 +95,7 @@ ASSETS.cli.config do |cnf|
95
95
 
96
96
  desc = "Includes in API updates ONLY people that evaluate true as people excluded from periodic upates."
97
97
  options_set.add("-include-only-excluded", desc) do |options|
98
- options.deep_merge!(include: {only_excluded: true})
98
+ options.deep_merge!(include: {excluded: {only: true}})
99
99
  end
100
100
 
101
101
  desc = "Ignores threshold limitations on requests for this session (skip batch belt)"
@@ -134,8 +134,11 @@ module Eco
134
134
  to_a.group_by(&block) if block
135
135
  end
136
136
 
137
- def to_h(attr)
138
- return {} if !attr
137
+ # By a specific `attr` or a block
138
+ # @note either one or the other should be present
139
+ def to_h(attr, &block)
140
+ return to_a.group_by(&block) if block
141
+ raise "And attr or a block are required. Given attr: #{attr}" unless attr
139
142
  to_a.group_by { |object| object.method(attr).call }
140
143
  end
141
144
  # @!endgroup
data/lib/eco/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Eco
2
- VERSION = "2.0.24"
2
+ VERSION = "2.0.25"
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.0.24
4
+ version: 2.0.25
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oscar Segura