eco-helpers 2.7.5 → 2.7.7

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: c1fab21c8ca261ba89cae934637d3dab47fc613e958a9b3e281025e8a65a1aaf
4
- data.tar.gz: 76bafdf3364c2de16005575b31c134e56155ba29c6ecd980005c816105a5c886
3
+ metadata.gz: 6610ab2a1e5ce009eedeac2deafb3232d3c8266123b6f8784b5f4542e4f4b24b
4
+ data.tar.gz: 809cab1fd71f909e04fa16a3ac84cc053d564b1888511defc91126b9765b4008
5
5
  SHA512:
6
- metadata.gz: c5938821d5251b6fad7c87ff1cabd97526b4831a68c3f5a1d877886209f7d17b2f08c52e0a3d4d8560a6905abe01afae44a5b4640db1856bbf05ccbfeb368926
7
- data.tar.gz: f13c1eb5103017726144b5b2924137af7fe501899c6c7c521ff52111e4f8e2f6a005eac005adb52b1ea5bfd1bb0da49bc8aaac71ae1c93b72534923ccf4beb43
6
+ metadata.gz: bdfdf7afeff13f228c47febc677e6c39f8639dc4bdb6f0bee60d836418a8f14a1dc9ac9919fc7c5986d20386203719db597418e03f1c3dad82a755016a5ae4a1
7
+ data.tar.gz: 868e92852ec88fd3315080883f4c4854ef80ec04ca85d46c76ac62e995233e225dcf99b9ceadb51436546400968e72152933163dfdfb244a5e7d0151df89361f
data/CHANGELOG.md CHANGED
@@ -1,13 +1,34 @@
1
1
  # Change Log
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
- ## [2.7.5] - 2024-05-xx
4
+ ## [2.7.8] - 2024-05-xx
5
5
 
6
6
  ### Added
7
7
  ### Changed
8
8
  ### Fixed
9
9
 
10
- ## [2.7.5] - 2024-05-08
10
+ ## [2.7.7] - 2024-05-16
11
+
12
+ ### Added
13
+ ### Changed
14
+ ### Fixed
15
+ - `Eco::API::UseCases::OozeSamples::TargetOozesUpdateCase`
16
+ - default prompt to user to `Y` when in remote mode.
17
+
18
+ ## [2.7.6] - 2024-05-16
19
+
20
+ ### Changed
21
+ - upgraded `ecoportal-api-graphql` gem, and `ecoportal-api` gem
22
+ - `Eco::API::Common::People::Entries` (**optimization**)
23
+ - Remove supervisors order
24
+ - It could create cyclic supervisors.
25
+ - `Eco::API::MicroCases#set_supervisor` slight improvemnent to prevent cyclic supers (self + added one to one)
26
+
27
+ ### Fixed
28
+ - `Eco::API::UseCases::GraphQL::Helpers::Location::Command::Diff::AsUpdate`
29
+ - `classificationIds` should be always an `Array`
30
+
31
+ ## [2.7.5] - 2024-05-07
11
32
 
12
33
  ### Fixed
13
34
  - `Eco::API::UseCases::GraphQL::Utils` typo
data/eco-helpers.gemspec CHANGED
@@ -30,9 +30,9 @@ Gem::Specification.new do |spec|
30
30
  spec.add_development_dependency "yard", ">= 0.9.34", "< 1"
31
31
  spec.add_development_dependency "redcarpet", ">= 3.6.0", "< 4"
32
32
 
33
- spec.add_dependency 'ecoportal-api', '>= 0.9.7', '< 0.10'
33
+ spec.add_dependency 'ecoportal-api', '>= 0.9.8', '< 0.10'
34
34
  spec.add_dependency 'ecoportal-api-v2', '>= 1.1.8', '< 1.2'
35
- spec.add_dependency 'ecoportal-api-graphql', '>= 0.3.16', '< 0.4'
35
+ spec.add_dependency 'ecoportal-api-graphql', '>= 0.3.17', '< 0.4'
36
36
  spec.add_dependency 'aws-sdk-s3', '>= 1.142.0', '< 2'
37
37
  spec.add_dependency 'aws-sdk-ses', '>= 1.58.0', '< 2'
38
38
  spec.add_dependency 'dotenv', '>= 2.8.1', '< 3'
@@ -1,3 +1,4 @@
1
+ # rubocop:disable Style/Attr
1
2
  module Eco
2
3
  module API
3
4
  module Common
@@ -6,13 +7,15 @@ module Eco
6
7
  # @attr_reader entries [Array<Eco::API::Common::PeopleEntry] a pure `Array` object.
7
8
  class Entries < Eco::Language::Models::Collection
8
9
  # Error class that allows to handle cases where multiple entries were found for the same criterion.
9
- # @note its main purpose to prevent the false pairing of duplicates or override information between different people.
10
+ # @note its main purpose to prevent the false pairing of duplicates or override information between
11
+ # different people.
10
12
  class MultipleSearchResults < StandardError
11
13
  attr_reader :candidates, :property
12
14
 
13
15
  # @param msg [String] the basic message error.
14
16
  # @param candiates [Array<PersonEntry>] the entries that match the same search criterion.
15
- # @param property [String] the property of the entry model that triggered the error (base of the search criterion).
17
+ # @param property [String] the property of the entry model that triggered the error
18
+ # (base of the search criterion).
16
19
  def initialize(msg, candidates: [], property: "email")
17
20
  @candidates = candidates
18
21
  @property = property
@@ -46,8 +49,6 @@ module Eco
46
49
 
47
50
  alias_method :entries, :to_a
48
51
 
49
- include Eco::API::Common::People::SupervisorHelpers
50
-
51
52
  def initialize(data = [], klass:, factory:)
52
53
  super(data, klass: klass, factory: factory)
53
54
  @caches_init = false
@@ -136,8 +137,8 @@ module Eco
136
137
  # Override `each` to make it work with supervisor hiearchy
137
138
  def each(&block)
138
139
  return to_enum(:each) unless block
139
- @array_supers = sort_by_supervisors(@items) unless @caches_init
140
- @array_supers.each(&block)
140
+
141
+ @items.each(&block)
141
142
  end
142
143
 
143
144
  def exclude(object)
@@ -208,7 +209,6 @@ module Eco
208
209
  @by_id = no_nil_key(to_h)
209
210
  @by_external_id = no_nil_key(to_h('external_id'))
210
211
  @by_email = no_nil_key(to_h('email'))
211
- @array_supers = sort_by_supervisors(@items)
212
212
  @caches_init = true
213
213
  end
214
214
 
@@ -220,3 +220,5 @@ module Eco
220
220
  end
221
221
  end
222
222
  end
223
+
224
+ # rubocop:enable Style/Attr
@@ -11,40 +11,51 @@ module Eco
11
11
  # @yield [supervisor_id] callback when the supervisor_id is **unknown** (not `nil` nor any one's in `people`).
12
12
  # @yieldparam supervisor_id [String] the **unknown** `supervisor_id`.
13
13
  def set_supervisor(person, sup_id, people, options)
14
- unless options.dig(:exclude, :core) || options.dig(:exclude, :supervisor)
15
- return false if sup_id && ((person.id == sup_id) || (person.external_id == sup_id))
16
- cur_id = person.supervisor_id
17
- cur_super = cur_id && with_supervisor(cur_id, people)
18
- micro.with_supervisor(sup_id, people) do |new_super|
19
- if !sup_id
20
- person.supervisor_id = nil
21
- descrease_subordinates(cur_super)
22
- elsif new_super && id = new_super.id
23
- person.supervisor_id = id
24
- descrease_subordinates(cur_super)
25
- increase_subordinates(new_super)
26
- elsif !block_given?
27
- descrease_subordinates(cur_super)
28
- person.supervisor_id = sup_id
29
- else
30
- yield(sup_id) if block_given?
31
- end
14
+ return false if options.dig(:exclude, :core) || options.dig(:exclude, :supervisor)
15
+ return false if sup_id && ((person.id == sup_id) || (person.external_id == sup_id))
16
+
17
+ cur_id = person.supervisor_id
18
+ cur_super = cur_id && with_supervisor(cur_id, people)
19
+
20
+ micro.with_supervisor(sup_id, people) do |new_super|
21
+ if !sup_id
22
+ person.supervisor_id = nil
23
+ descrease_subordinates(cur_super)
24
+ elsif new_super && (id = new_super.id)
25
+ set_supervisor(new_super, nil, people, options) if new_super_direct_cyclic?(person, new_super)
26
+ person.supervisor_id = id
27
+ descrease_subordinates(cur_super)
28
+ increase_subordinates(new_super)
29
+ elsif !block_given?
30
+ descrease_subordinates(cur_super)
31
+ person.supervisor_id = sup_id
32
+ elsif block_given?
33
+ yield(sup_id)
32
34
  end
33
35
  end
34
36
  end
35
37
 
36
38
  private
37
39
 
40
+ def new_super_direct_cyclic?(person, new_super)
41
+ return false unless new_super.is_a?(Ecoportal::API::V1::Person)
42
+ return false if new_super.supervisor_id.nil?
43
+ return true if person.id == new_super.id
44
+ return true if new_super.supervisor_id == person.id
45
+ return true if new_super.supervisor_id == person.external_id
46
+ false
47
+ end
48
+
38
49
  def descrease_subordinates(person, by = 1)
39
- if person.is_a?(Ecoportal::API::V1::Person)
40
- person.subordinates -= by
41
- end
50
+ return unless person.is_a?(Ecoportal::API::V1::Person)
51
+
52
+ person.subordinates -= by
42
53
  end
43
54
 
44
55
  def increase_subordinates(person, by = 1)
45
- if person.is_a?(Ecoportal::API::V1::Person)
46
- person.subordinates += by
47
- end
56
+ return unless person.is_a?(Ecoportal::API::V1::Person)
57
+
58
+ person.subordinates += by
48
59
  end
49
60
  end
50
61
  end
@@ -11,7 +11,12 @@ class Eco::API::UseCases::GraphQL::Helpers::Location::Command::Diff
11
11
  def diff_hash(after_id_update: true) # rubocop:disable Metrics/AbcSize
12
12
  super().tap do |h|
13
13
  h.delete('archived')
14
- h['classificationIds'] = h.delete('classifications') if h.key?('classifications')
14
+
15
+ if h.key?('classifications')
16
+ class_ids = h.delete('classifications')
17
+ class_ids = [class_ids].flatten.compact unless class_ids.is_a?(Array)
18
+ h['classificationIds'] = class_ids
19
+ end
15
20
 
16
21
  if archive? || insert?
17
22
  # We assume archives do not have `move` nor update `id` or `name`
@@ -50,7 +50,14 @@ class Eco::API::UseCases::OozeSamples::TargetOozesUpdateCase < Eco::API::UseCase
50
50
  dups_str = dups.count.positive? ? "There are #{dups.count} duplicated ids" : "No duplicates detected"
51
51
  msg = "Total target entries: #{target_ids.count} (#{dups_str})"
52
52
 
53
- session.prompt_user("Do you want to proceed (y/N):", explanation: msg, default: "N", timeout: 10) do |res|
53
+ default_answer = session.config.run_mode_remote?? "Y" : "N"
54
+
55
+ session.prompt_user(
56
+ "Do you want to proceed (y/N):",
57
+ explanation: msg,
58
+ default: default_answer,
59
+ timeout: 10
60
+ ) do |res|
54
61
  unless res.upcase.start_with?("Y")
55
62
  puts "..."
56
63
  log(:info) { "Aborting script..." }
data/lib/eco/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Eco
2
- VERSION = '2.7.5'.freeze
2
+ VERSION = '2.7.7'.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.5
4
+ version: 2.7.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oscar Segura
@@ -116,7 +116,7 @@ dependencies:
116
116
  requirements:
117
117
  - - ">="
118
118
  - !ruby/object:Gem::Version
119
- version: 0.9.7
119
+ version: 0.9.8
120
120
  - - "<"
121
121
  - !ruby/object:Gem::Version
122
122
  version: '0.10'
@@ -126,7 +126,7 @@ dependencies:
126
126
  requirements:
127
127
  - - ">="
128
128
  - !ruby/object:Gem::Version
129
- version: 0.9.7
129
+ version: 0.9.8
130
130
  - - "<"
131
131
  - !ruby/object:Gem::Version
132
132
  version: '0.10'
@@ -156,7 +156,7 @@ dependencies:
156
156
  requirements:
157
157
  - - ">="
158
158
  - !ruby/object:Gem::Version
159
- version: 0.3.16
159
+ version: 0.3.17
160
160
  - - "<"
161
161
  - !ruby/object:Gem::Version
162
162
  version: '0.4'
@@ -166,7 +166,7 @@ dependencies:
166
166
  requirements:
167
167
  - - ">="
168
168
  - !ruby/object:Gem::Version
169
- version: 0.3.16
169
+ version: 0.3.17
170
170
  - - "<"
171
171
  - !ruby/object:Gem::Version
172
172
  version: '0.4'