eco-helpers 2.4.6 → 2.4.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +23 -1
- data/eco-helpers.gemspec +1 -1
- data/lib/eco/api/organization/tag_tree.rb +32 -12
- data/lib/eco/api/session/config/api.rb +1 -1
- data/lib/eco/api/usecases/default_cases/csv_to_tree_case/helper.rb +6 -1
- data/lib/eco/api/usecases/default_cases/hris_case.rb +1 -1
- data/lib/eco/data/hashes/array_diff.rb +13 -4
- data/lib/eco/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: facf3e640f8af36beba49a9da6eb7c72cb70b4a07ef93602ee70898cce31c356
|
4
|
+
data.tar.gz: 304bb16fdefd0db6ad63b524a654aed990375a24630565d59cfb6fa4470e94da
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6d4b1882f5c042ceeeee46bfb6e1604204092a108409c882df2f82e125259cd11551ce90e48c40cf5c7cdf50286eda42b624c9cd24d9e1ea13d4a8bb3203d9b2
|
7
|
+
data.tar.gz: 91061e3b0d8caafc59fbd77ca726cf84c83d459eb1bad420932ad3482842d57acd1a38a35373a82078638b6c7e41e570a6c7f2adb84a319a38c61509555d2bc9
|
data/CHANGELOG.md
CHANGED
@@ -1,12 +1,34 @@
|
|
1
1
|
# Change Log
|
2
2
|
All notable changes to this project will be documented in this file.
|
3
3
|
|
4
|
-
## [2.4.
|
4
|
+
## [2.4.9] - 2023-04-xx
|
5
5
|
|
6
6
|
### Added
|
7
7
|
### Changed
|
8
8
|
### Fixed
|
9
9
|
|
10
|
+
## [2.4.8] - 2023-04-03
|
11
|
+
|
12
|
+
### Added
|
13
|
+
- `Eco::API::Organization::TagTree#ancestors` returns the ancestor nodes.
|
14
|
+
|
15
|
+
## [2.4.7] - 2023-04-03
|
16
|
+
|
17
|
+
### Added
|
18
|
+
- `Eco::Data::Hashes::ArrayDiff#diffs?`
|
19
|
+
- `Eco::API::Organization::TagTree` added methods:
|
20
|
+
- `#source` => to expose the original doc
|
21
|
+
- `#all_nodes` => to implement the block call
|
22
|
+
|
23
|
+
### Changed
|
24
|
+
- Upgraded `ecoportal-api-graphql` **gem**
|
25
|
+
|
26
|
+
### Fixed
|
27
|
+
- `Eco::API::Session::Config::Api` **new `graphql` api** was missing `host`
|
28
|
+
- `Eco::API::UseCases::DefaultCases::CsvToTree::Helper`
|
29
|
+
- `#nodes_from_csv` assumed unique top level tag and not present
|
30
|
+
- This fix completes this feature (as top level tags were not there)
|
31
|
+
|
10
32
|
## [2.4.6] - 2023-04-02
|
11
33
|
|
12
34
|
### Added
|
data/eco-helpers.gemspec
CHANGED
@@ -32,7 +32,7 @@ Gem::Specification.new do |spec|
|
|
32
32
|
|
33
33
|
spec.add_dependency 'ecoportal-api', '>= 0.9.3', '< 0.10'
|
34
34
|
spec.add_dependency 'ecoportal-api-v2', '>= 1.1.1', '< 1.2'
|
35
|
-
spec.add_dependency 'ecoportal-api-graphql', '>= 0.3.
|
35
|
+
spec.add_dependency 'ecoportal-api-graphql', '>= 0.3.5', '< 0.4'
|
36
36
|
spec.add_dependency 'aws-sdk-s3', '>= 1.83.0', '< 2'
|
37
37
|
spec.add_dependency 'aws-sdk-ses', '>= 1.36.0', '< 2'
|
38
38
|
spec.add_dependency 'dotenv', '>= 2.7.6', '< 2.8'
|
@@ -13,6 +13,8 @@ module Eco
|
|
13
13
|
attr_reader :depth, :path
|
14
14
|
attr_reader :enviro
|
15
15
|
|
16
|
+
attr_reader :source
|
17
|
+
|
16
18
|
include Enumerable
|
17
19
|
|
18
20
|
# @example Node format:
|
@@ -42,20 +44,20 @@ module Eco
|
|
42
44
|
if @source.is_a?(Array)
|
43
45
|
@id = id
|
44
46
|
@name = name
|
45
|
-
@
|
47
|
+
@raw_nodes = @source
|
46
48
|
else
|
47
49
|
@id = @source.values_at('tag', 'id').compact.first&.upcase
|
48
50
|
@name = @source['name']
|
49
|
-
@archived = @source
|
50
|
-
@archived_token
|
51
|
-
@weight
|
52
|
-
@
|
51
|
+
@archived = @source['archived'] || false
|
52
|
+
@archived_token = @source['archived_token']
|
53
|
+
@source['weight'] = @weight = @source['weight'] || _weight
|
54
|
+
@raw_nodes = @source['nodes'] || []
|
53
55
|
end
|
54
56
|
|
55
57
|
@path = path || []
|
56
58
|
@path.push(@id) unless top?
|
57
59
|
|
58
|
-
@nodes = @
|
60
|
+
@nodes = @raw_nodes.map.with_index do |cnode, idx|
|
59
61
|
TagTree.new(cnode, depth: depth + 1, path: @path.dup, parent: self, _weight: idx, enviro: @enviro)
|
60
62
|
end
|
61
63
|
|
@@ -82,12 +84,27 @@ module Eco
|
|
82
84
|
|
83
85
|
# All actual nodes of this tree
|
84
86
|
# @note order is that of the parent to child relationships
|
85
|
-
# @return [Array
|
87
|
+
# @return [Array<TagTree>]
|
86
88
|
def all_nodes(&block)
|
87
|
-
[].tap do |
|
88
|
-
|
89
|
+
[].tap do |out_nodes|
|
90
|
+
unless top?
|
91
|
+
out_nodes.push(self)
|
92
|
+
yield(self) if block_given?
|
93
|
+
end
|
89
94
|
nodes.each do |node|
|
90
|
-
|
95
|
+
out_nodes.concat(node.all_nodes(&block))
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
# All the acenstor nodes of the current node
|
101
|
+
# @note it does not include the current node
|
102
|
+
# @return [Array<TagTree>] ancestors sorted from top to bottom.
|
103
|
+
def ancestors
|
104
|
+
[].tap do |ans|
|
105
|
+
unless parent.top?
|
106
|
+
ans << parent
|
107
|
+
ans.concat(parent.ancestors)
|
91
108
|
end
|
92
109
|
end
|
93
110
|
end
|
@@ -109,8 +126,11 @@ module Eco
|
|
109
126
|
nodes_json
|
110
127
|
else
|
111
128
|
{
|
112
|
-
"id"
|
113
|
-
"
|
129
|
+
"id" => tag,
|
130
|
+
"archived" => archived,
|
131
|
+
"archived_token" => archived_token,
|
132
|
+
"weight" => weight,
|
133
|
+
"nodes" => nodes_json
|
114
134
|
}
|
115
135
|
end
|
116
136
|
end
|
@@ -171,7 +171,7 @@ module Eco
|
|
171
171
|
when :v2
|
172
172
|
klass.new(user_key: user_key, org_key: external_key, host: host, logger: logger)
|
173
173
|
when :graphql
|
174
|
-
klass.new(org_id: org_id, email: email, pass: pass)
|
174
|
+
klass.new(host: host, org_id: org_id, email: email, pass: pass)
|
175
175
|
end.tap do |api|
|
176
176
|
unless !api || log_connection?
|
177
177
|
@logger.info("Created api#{self.version(version)} connection on '#{name}' enviro, pointing to '#{host}' in '#{mode}' mode")
|
@@ -25,11 +25,16 @@ class Eco::API::UseCases::DefaultCases::CsvToTree
|
|
25
25
|
node = Node.new(i, *values)
|
26
26
|
prev_node ||= node
|
27
27
|
|
28
|
-
|
28
|
+
# If node is nested in prev_node or is a sibling thereof
|
29
|
+
if prev_node.raw_level <= node.raw_level\
|
30
|
+
# Make sure parent is among upper level tags
|
29
31
|
node.set_high_levels(prev_node)
|
30
32
|
else
|
31
33
|
if parent_node = prev_nodes[node.raw_level - 1]
|
32
34
|
node.set_high_levels(parent_node)
|
35
|
+
elsif node.raw_level == 1
|
36
|
+
# It is expected not to have parent
|
37
|
+
#puts "Node '#{node.raw_tag}' doesn't have parent, but it's top level tag"
|
33
38
|
else
|
34
39
|
raise "Node '#{node.raw_tag}' (#{node.row_num} row) doesn't have parent"
|
35
40
|
end
|
@@ -44,7 +44,7 @@ class Eco::API::UseCases::DefaultCases::HrisCase < Eco::API::Common::Loaders::Us
|
|
44
44
|
other_people = people.group_by_schema.values_at(*other_schemas).map(&:to_a).flatten
|
45
45
|
if other_people.length > 3
|
46
46
|
msg = "There are #{other_people.length} people in schemas other than #{active_schema.name}."
|
47
|
-
msg << " Please, use the filter option '-
|
47
|
+
msg << " Please, use the filter option '-schema-id SchemaName' for the 'hris' case to only include those of that schema"
|
48
48
|
msg << " in the current update. The HRIS case identifies people that are not in the file as leavers"
|
49
49
|
msg << " (as it will remove the account of all the people of other schemas if they are not in the input file)."
|
50
50
|
msg << "\n For example: -schema-id '#{active_schema.name.downcase}'"
|
@@ -56,15 +56,24 @@ module Eco
|
|
56
56
|
# - It also allows to know the original value
|
57
57
|
# @return [Hash] where `key` is the key of the record, and `value` a `DiffResult` object
|
58
58
|
def diffs
|
59
|
-
@diffs ||=
|
59
|
+
@diffs ||= source_results.select do |res|
|
60
|
+
res.diff?
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
# @return [Boolean] wheter or not there are differences.
|
65
|
+
def diffs?
|
66
|
+
!diffs.empty?
|
67
|
+
end
|
68
|
+
|
69
|
+
def source_results
|
70
|
+
@source_results ||= paired_sources.each_with_object([]) do |(src1, src2), res|
|
60
71
|
args = {
|
61
72
|
key: key,
|
62
73
|
compare: compared_attrs,
|
63
74
|
case_sensitive: case_sensitive?
|
64
75
|
}
|
65
|
-
diff_result_class.new(src1, src2, **args)
|
66
|
-
diffs << res if res.diff?
|
67
|
-
end
|
76
|
+
res << diff_result_class.new(src1, src2, **args)
|
68
77
|
end
|
69
78
|
end
|
70
79
|
|
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.4.
|
4
|
+
version: 2.4.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Oscar Segura
|
@@ -156,7 +156,7 @@ dependencies:
|
|
156
156
|
requirements:
|
157
157
|
- - ">="
|
158
158
|
- !ruby/object:Gem::Version
|
159
|
-
version: 0.3.
|
159
|
+
version: 0.3.5
|
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.5
|
170
170
|
- - "<"
|
171
171
|
- !ruby/object:Gem::Version
|
172
172
|
version: '0.4'
|