eco-helpers 2.4.5 → 2.4.7
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +31 -2
- data/eco-helpers.gemspec +1 -1
- data/lib/eco/api/organization/tag_tree.rb +16 -9
- data/lib/eco/api/session/config/api.rb +1 -1
- data/lib/eco/api/session/config/tagtree.rb +4 -4
- data/lib/eco/api/session.rb +2 -2
- 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: 0ab1e50c5ccc57fd84bd6b21b40a9d455455e3457c89248f7bf60177fe82293a
|
4
|
+
data.tar.gz: 169a31ded9574a5fd8a135a0cfe3f388fe71c48e87f7f67969e12036ba40ab3f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7de4657000ee0181e9c7dcea3536365c5a66fc26d5b25999715129ce4ebed459ba67042de42736b96879b617aba2adc063f92403f0ff063cac13fd5301562191
|
7
|
+
data.tar.gz: e9518629a51f623b07d795eedad394682b53bc23edf1389cb2185f34519ccaed8cf2c746eba8c8ae0c4e12b41068b7444f2f6f263e3a30cd5ab91aa45be09185
|
data/CHANGELOG.md
CHANGED
@@ -1,16 +1,45 @@
|
|
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.8] - 2023-04-xx
|
5
5
|
|
6
6
|
### Added
|
7
7
|
### Changed
|
8
8
|
### Fixed
|
9
9
|
|
10
|
+
## [2.4.7] - 2023-04-03
|
11
|
+
|
12
|
+
### Added
|
13
|
+
- `Eco::Data::Hashes::ArrayDiff#diffs?`
|
14
|
+
- `Eco::API::Organization::TagTree` added methods:
|
15
|
+
- `#source` => to expose the original doc
|
16
|
+
- `#all_nodes` => to implement the block call
|
17
|
+
|
18
|
+
### Changed
|
19
|
+
- Upgraded `ecoportal-api-graphql` **gem**
|
20
|
+
|
21
|
+
### Fixed
|
22
|
+
- `Eco::API::Session::Config::Api` **new `graphql` api** was missing `host`
|
23
|
+
- `Eco::API::UseCases::DefaultCases::CsvToTree::Helper`
|
24
|
+
- `#nodes_from_csv` assumed unique top level tag and not present
|
25
|
+
- This fix completes this feature (as top level tags were not there)
|
26
|
+
|
27
|
+
## [2.4.6] - 2023-04-02
|
28
|
+
|
29
|
+
### Added
|
30
|
+
- `Eco::API::Organization::TagTree` added support for `archived_token`
|
31
|
+
- Added support for `block` in
|
32
|
+
- `Eco::API::Session#live_tree`
|
33
|
+
- `Eco::API::Session::Config::Tagtree` in `#live_trees` and `live_tree`
|
34
|
+
|
35
|
+
### Changed
|
36
|
+
- Upgraded `ecoportal-api-graphql` **gem**
|
37
|
+
|
38
|
+
|
10
39
|
## [2.4.5] - 2023-03-31
|
11
40
|
|
12
41
|
### Added
|
13
|
-
- `Eco::API
|
42
|
+
- `Eco::API::Organization::TagTree` support for `archived` and `weight` properties
|
14
43
|
- `Eco::Data::Hashes::ArrayDiff` and `Eco::Data::Hashes::DiffResult`
|
15
44
|
- Enable easy comparison of array of hashes
|
16
45
|
- Input data can be diverse
|
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'
|
@@ -5,13 +5,16 @@ module Eco
|
|
5
5
|
class TagTree
|
6
6
|
attr_accessor :id
|
7
7
|
alias_method :tag, :id
|
8
|
-
attr_accessor :name, :
|
8
|
+
attr_accessor :name, :weight
|
9
|
+
attr_accessor :archived, :archived_token
|
9
10
|
|
10
11
|
attr_reader :parent
|
11
12
|
attr_reader :nodes, :children_count
|
12
13
|
attr_reader :depth, :path
|
13
14
|
attr_reader :enviro
|
14
15
|
|
16
|
+
attr_reader :source
|
17
|
+
|
15
18
|
include Enumerable
|
16
19
|
|
17
20
|
# @example Node format:
|
@@ -41,19 +44,20 @@ module Eco
|
|
41
44
|
if @source.is_a?(Array)
|
42
45
|
@id = id
|
43
46
|
@name = name
|
44
|
-
@
|
47
|
+
@raw_nodes = @source
|
45
48
|
else
|
46
49
|
@id = @source.values_at('tag', 'id').compact.first&.upcase
|
47
50
|
@name = @source['name']
|
48
|
-
@archived = @source
|
49
|
-
@
|
50
|
-
@
|
51
|
+
@archived = @source['archived'] || false
|
52
|
+
@archived_token = @source['archived_token']
|
53
|
+
@source['weight'] = @weight = @source['weight'] || _weight
|
54
|
+
@raw_nodes = @source['nodes'] || []
|
51
55
|
end
|
52
56
|
|
53
57
|
@path = path || []
|
54
58
|
@path.push(@id) unless top?
|
55
59
|
|
56
|
-
@nodes = @
|
60
|
+
@nodes = @raw_nodes.map.with_index do |cnode, idx|
|
57
61
|
TagTree.new(cnode, depth: depth + 1, path: @path.dup, parent: self, _weight: idx, enviro: @enviro)
|
58
62
|
end
|
59
63
|
|
@@ -82,10 +86,13 @@ module Eco
|
|
82
86
|
# @note order is that of the parent to child relationships
|
83
87
|
# @return [Array[]]
|
84
88
|
def all_nodes(&block)
|
85
|
-
[].tap do |
|
86
|
-
|
89
|
+
[].tap do |out_nodes|
|
90
|
+
unless top?
|
91
|
+
out_nodes.push(self)
|
92
|
+
yield(self) if block_given?
|
93
|
+
end
|
87
94
|
nodes.each do |node|
|
88
|
-
|
95
|
+
out_nodes.concat(node.all_nodes(&block))
|
89
96
|
end
|
90
97
|
end
|
91
98
|
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")
|
@@ -20,9 +20,9 @@ module Eco
|
|
20
20
|
end
|
21
21
|
|
22
22
|
# Among all the locations structures it selects the one with more location nodes
|
23
|
-
def live_tree(enviro: nil, include_archived: false)
|
23
|
+
def live_tree(enviro: nil, include_archived: false, &block)
|
24
24
|
return @live_tree if instance_variable_defined?(:@live_tree) && @live_tree.enviro == enviro
|
25
|
-
trees = live_trees(enviro: enviro, include_archived: include_archived)
|
25
|
+
trees = live_trees(enviro: enviro, include_archived: include_archived, &block)
|
26
26
|
@live_tree = trees.reject do |tree|
|
27
27
|
tree.empty?
|
28
28
|
end.max do |a,b|
|
@@ -36,7 +36,7 @@ module Eco
|
|
36
36
|
end
|
37
37
|
|
38
38
|
# Retrieves all the location structures of the organisation
|
39
|
-
def live_trees(enviro: nil, include_archived: false)
|
39
|
+
def live_trees(enviro: nil, include_archived: false, &block)
|
40
40
|
[].tap do |eco_trees|
|
41
41
|
next unless apis.active_api.version_available?(:graphql)
|
42
42
|
next unless graphql = apis.api(version: :graphql)
|
@@ -44,7 +44,7 @@ module Eco
|
|
44
44
|
includeArchived: include_archived,
|
45
45
|
includeUnpublished: false
|
46
46
|
}
|
47
|
-
next unless trees = graphql.currentOrganization.locationStructures(**kargs)
|
47
|
+
next unless trees = graphql.currentOrganization.locationStructures(**kargs, &block)
|
48
48
|
trees.each do |tree|
|
49
49
|
args = { enviro: enviro, id: tree.id, name: tree.name}
|
50
50
|
eco_tree = Eco::API::Organization::TagTree.new(tree.treeify, **args)
|
data/lib/eco/api/session.rb
CHANGED
@@ -45,8 +45,8 @@ module Eco
|
|
45
45
|
end
|
46
46
|
|
47
47
|
# @see Eco::API::Session::Config#live_tree
|
48
|
-
def live_tree(include_archived: false)
|
49
|
-
config.live_tree(enviro: enviro)
|
48
|
+
def live_tree(include_archived: false, &block)
|
49
|
+
config.live_tree(enviro: enviro, &block)
|
50
50
|
end
|
51
51
|
|
52
52
|
# @see Eco::API::Session::Config#schemas
|
@@ -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.7
|
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'
|