eco-helpers 2.7.5 → 2.7.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -2
- data/eco-helpers.gemspec +2 -2
- data/lib/eco/api/common/people/entries.rb +9 -7
- data/lib/eco/api/microcases/set_supervisor.rb +35 -24
- data/lib/eco/api/usecases/graphql/helpers/location/command/diff/as_update.rb +6 -1
- data/lib/eco/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7c7e7c6c61dc2fa5886b5a396f54051e216bf8ffbf6e31ab98388b3ed21c5e5b
|
4
|
+
data.tar.gz: 4cea27b25b939efd57a4bfcf1d540df660f94cd7b48be45cf96b67dde5d01033
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4c0a48790cf660cb326fa6a06e60e8fc4395f4cfcefd00ca71aa79be79daceb8bf5e4dfd74c33957e07f1cb1f7d8cf298fd062544ecdecd620681c33706fec57
|
7
|
+
data.tar.gz: 0dfb7e2c7ad703782373bd6c6b24bacc872238009cc9552998e40c55ff05f7bb61b667ee65d333e55b3623f8b139792ea42f5f3eab6a2f737ff182c01b28cd16
|
data/CHANGELOG.md
CHANGED
@@ -1,13 +1,21 @@
|
|
1
1
|
# Change Log
|
2
2
|
All notable changes to this project will be documented in this file.
|
3
3
|
|
4
|
-
## [2.7.
|
4
|
+
## [2.7.6] - 2024-05-xx
|
5
5
|
|
6
6
|
### Added
|
7
7
|
### Changed
|
8
|
+
- upgraded `ecoportal-api-graphql` gem, and `ecoportal-api` gem
|
9
|
+
- `Eco::API::Common::People::Entries` (**optimization**)
|
10
|
+
- Remove supervisors order
|
11
|
+
- It could create cyclic supervisors.
|
12
|
+
- `Eco::API::MicroCases#set_supervisor` slight improvemnent to prevent cyclic supers (self + added one to one)
|
13
|
+
|
8
14
|
### Fixed
|
15
|
+
- `Eco::API::UseCases::GraphQL::Helpers::Location::Command::Diff::AsUpdate`
|
16
|
+
- `classificationIds` should be always an `Array`
|
9
17
|
|
10
|
-
## [2.7.5] - 2024-05-
|
18
|
+
## [2.7.5] - 2024-05-07
|
11
19
|
|
12
20
|
### Fixed
|
13
21
|
- `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.
|
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.
|
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
|
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
|
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
|
-
|
140
|
-
@
|
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
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
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
|
-
|
40
|
-
|
41
|
-
|
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
|
-
|
46
|
-
|
47
|
-
|
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
|
-
|
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`
|
data/lib/eco/version.rb
CHANGED
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.
|
4
|
+
version: 2.7.6
|
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.
|
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.
|
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.
|
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.
|
169
|
+
version: 0.3.17
|
170
170
|
- - "<"
|
171
171
|
- !ruby/object:Gem::Version
|
172
172
|
version: '0.4'
|