eco-helpers 3.2.1 → 3.2.3
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/.rubocop.yml +1 -1
- data/CHANGELOG.md +36 -1
- data/eco-helpers.gemspec +3 -3
- data/lib/eco/api/common/loaders/config/workflow/mailer.rb +1 -0
- data/lib/eco/api/common/people/person_entry.rb +6 -1
- data/lib/eco/api/common/people/person_parser.rb +1 -0
- data/lib/eco/api/microcases/people/manage/cache.rb +21 -16
- data/lib/eco/api/microcases/people/manage/filename.rb +29 -0
- data/lib/eco/api/microcases/people/manage/load.rb +6 -48
- data/lib/eco/api/microcases/people/manage/load_cache.rb +29 -0
- data/lib/eco/api/microcases/people/manage/refresh.rb +5 -3
- data/lib/eco/api/microcases/people/manage.rb +4 -0
- data/lib/eco/api/organization/tag_tree.rb +11 -4
- data/lib/eco/api/session/batch/searcher.rb +3 -3
- data/lib/eco/api/session/config/people.rb +23 -20
- data/lib/eco/api/usecases/default/locations/tagtree_upload_case.rb +20 -2
- data/lib/eco/api/usecases/graphql/helpers/location/base/tree_tracking.rb +14 -7
- data/lib/eco/api/usecases/graphql/helpers/location/base.rb +1 -1
- data/lib/eco/api/usecases/graphql/helpers/location/command/diff/as_update.rb +0 -1
- data/lib/eco/api/usecases/graphql/helpers/location/command/diffs/stages/diff_sortable/for_archive.rb +0 -1
- data/lib/eco/api/usecases/graphql/helpers/location/command/end_points/optimizations.rb +64 -0
- data/lib/eco/api/usecases/graphql/helpers/location/command/end_points.rb +96 -0
- data/lib/eco/api/usecases/graphql/helpers/location/command/input_unit_response.rb +69 -0
- data/lib/eco/api/usecases/graphql/helpers/location/command/result.rb +11 -10
- data/lib/eco/api/usecases/graphql/helpers/location/command/results.rb +120 -63
- data/lib/eco/api/usecases/graphql/helpers/location/command.rb +26 -26
- data/lib/eco/api/usecases/graphql/samples/location/command/dsl.rb +195 -37
- data/lib/eco/api/usecases/graphql/samples/location/command/results.rb +45 -13
- data/lib/eco/api/usecases/graphql/samples/location/command/service/tree_update.rb +0 -51
- data/lib/eco/api/usecases/graphql/samples/location/command/track_changed_ids.rb +6 -14
- data/lib/eco/api/usecases/graphql/samples/location/command.rb +1 -1
- data/lib/eco/api/usecases/graphql/samples/location/service/tree_diff/convertible/inputable.rb +4 -1
- data/lib/eco/api/usecases/graphql/samples/location/service/tree_diff.rb +6 -0
- data/lib/eco/api/usecases/graphql/samples/location/service/tree_to_list/converter/input.rb +1 -0
- data/lib/eco/api/usecases/lib/error_handling.rb +1 -1
- data/lib/eco/api/usecases/ooze_samples/helpers/creatable.rb +1 -0
- data/lib/eco/api/usecases/ooze_samples/helpers/rescuable.rb +1 -0
- data/lib/eco/api/usecases/samples/drivers/cli/sftp_cli.rb +1 -1
- data/lib/eco/api/usecases/samples/drivers/sftp_sample.rb +4 -1
- data/lib/eco/api/usecases/samples/drivers/url_pull_sample.rb +12 -9
- data/lib/eco/api/usecases/samples/people/filters/cli/require_id_cli.rb +5 -0
- data/lib/eco/api/usecases/samples/people/filters/cli/require_min_entries_cli.rb +5 -0
- data/lib/eco/api/usecases/samples/people/filters/require_id_sample.rb +61 -0
- data/lib/eco/api/usecases/samples/people/filters/require_min_entries_sample.rb +20 -0
- data/lib/eco/api/usecases/samples/people/filters.rb +7 -0
- data/lib/eco/api/usecases/samples/people.rb +12 -0
- data/lib/eco/api/usecases/samples.rb +1 -0
- data/lib/eco/cli_default/options.rb +5 -0
- data/lib/eco/data/hashes/array_diff.rb +14 -4
- data/lib/eco/data/locations/node_base/csv_convert.rb +9 -1
- data/lib/eco/data/locations/node_base/tag_validations.rb +2 -2
- data/lib/eco/data/locations/node_diff/nodes_diff/diffs_tree.rb +10 -3
- data/lib/eco/data/locations/node_diff/nodes_diff.rb +6 -0
- data/lib/eco/version.rb +1 -1
- metadata +23 -13
- data/lib/eco/api/usecases/graphql/helpers/location/command/optimizations.rb +0 -84
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b3323b0394649126c76ec4239eade6cca337049bd8f761f96aa7c66034717bd0
|
4
|
+
data.tar.gz: 3ddedb00b3b1e7674e014143e54e9cb46e52abb9482e9dfbc65dd4059fd0a70e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6b6126ec90b13ef1d2d985b384215a529b5818ff5d8139d96fe80d5c21c6a4a0b367cb9bb7bf8b92ff6ed61f3df525f35e2639b5160693cc0e2fd6109bfb02cb
|
7
|
+
data.tar.gz: d4b799b66943fda1cf7340f358520d1f30715e27866ba900615cedc5bab593200a53cb2ef72bb6ff04c8e8b4e7c4b1b6bd1b0240145240364f67f633fbb3fbd6
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
|
5
|
-
## [3.2.
|
5
|
+
## [3.2.4] - 2025-08-xx
|
6
6
|
|
7
7
|
### Added
|
8
8
|
|
@@ -10,6 +10,41 @@ All notable changes to this project will be documented in this file.
|
|
10
10
|
|
11
11
|
### Fixed
|
12
12
|
|
13
|
+
## [3.2.3] - 2025-08-21
|
14
|
+
|
15
|
+
### Added
|
16
|
+
|
17
|
+
- `Person#phone_number`
|
18
|
+
|
19
|
+
### Changed
|
20
|
+
|
21
|
+
- upgraded dependencies
|
22
|
+
- `ecoportal-api` gem
|
23
|
+
|
24
|
+
### Fixed
|
25
|
+
|
26
|
+
- Switched to use DRAFTs on RS updates
|
27
|
+
|
28
|
+
## [3.2.2] - 2025-06-11
|
29
|
+
|
30
|
+
### Added
|
31
|
+
|
32
|
+
- `PersonEntry#[]` accessor (onto `final_entry`)
|
33
|
+
- **Samples**:
|
34
|
+
- `require-id`
|
35
|
+
- `require-min-entries`
|
36
|
+
|
37
|
+
### Changed
|
38
|
+
|
39
|
+
- upgraded gem dependencies
|
40
|
+
- `Session::Batch::Searcher` silence low level messages.
|
41
|
+
- And better feedback on search.
|
42
|
+
- **Refactored** `Microcases` people get/cache/load helpers to reach a **unique access point** per functionality.
|
43
|
+
|
44
|
+
### Fixed
|
45
|
+
|
46
|
+
- The upgrade of the `ecoportal-api-graphql` **gem** fixes a bug introduced by a native release.
|
47
|
+
|
13
48
|
## [3.2.1] - 2025-05-17
|
14
49
|
|
15
50
|
### Changed
|
data/eco-helpers.gemspec
CHANGED
@@ -41,9 +41,9 @@ Gem::Specification.new do |spec|
|
|
41
41
|
spec.add_dependency 'bcrypt_pbkdf', '~> 1.0'
|
42
42
|
spec.add_dependency 'docx', '>= 0.8.0', '< 0.9'
|
43
43
|
spec.add_dependency 'dotenv', '~> 3'
|
44
|
-
spec.add_dependency 'ecoportal-api', '~> 0.10', '>= 0.10.
|
45
|
-
spec.add_dependency 'ecoportal-api-graphql', '~> 1.
|
46
|
-
spec.add_dependency 'ecoportal-api-v2', '~> 3.
|
44
|
+
spec.add_dependency 'ecoportal-api', '~> 0.10', '>= 0.10.14'
|
45
|
+
spec.add_dependency 'ecoportal-api-graphql', '~> 1.3', '>= 1.3.2'
|
46
|
+
spec.add_dependency 'ecoportal-api-v2', '~> 3.3', '>= 3.3.1'
|
47
47
|
spec.add_dependency 'ed25519', '~> 1.2'
|
48
48
|
spec.add_dependency 'fast_excel', '>= 0.5.0', '< 0.6'
|
49
49
|
spec.add_dependency 'fuzzy_match', '>= 2.1.0', '< 2.2'
|
@@ -9,7 +9,7 @@ module Eco
|
|
9
9
|
BOOLEAN_ATTRS = %w[
|
10
10
|
freemium accept_eula archived
|
11
11
|
].freeze
|
12
|
-
MULTI_ATTRS
|
12
|
+
MULTI_ATTRS = %w[
|
13
13
|
policy_group_ids filter_tags login_provider_ids starred_ids
|
14
14
|
].freeze
|
15
15
|
NUMERIC_ATTRS = %w[
|
@@ -98,6 +98,11 @@ module Eco
|
|
98
98
|
end
|
99
99
|
end
|
100
100
|
|
101
|
+
# Value on the final entry
|
102
|
+
def [](key)
|
103
|
+
final_entry[key]
|
104
|
+
end
|
105
|
+
|
101
106
|
# @note completely serialized entry.
|
102
107
|
# @return [Hash] entry `Hash` with **external** attribute names, and values and types thereof.
|
103
108
|
def external_entry # rubocop:disable Style/TrivialAccessors
|
@@ -4,29 +4,34 @@ module Eco
|
|
4
4
|
module People
|
5
5
|
module Manage
|
6
6
|
module Cache
|
7
|
-
# Helper to locally cache the people manager.
|
7
|
+
# Helper to locally cache the people manager (download via API).
|
8
8
|
# @param filename [String] the name of the file where the data should be cached.
|
9
9
|
# @return [Eco::API::Organization::People] the `People` object with the data.
|
10
|
-
def people_cache(filename = enviro.config.people.cache)
|
11
|
-
|
10
|
+
def people_cache(filename = enviro.config.people.cache, modifier: [:save])
|
11
|
+
modifier = [modifier].flatten
|
12
12
|
|
13
|
-
|
14
|
-
people = session.batch.get_people
|
15
|
-
secs = (Time.now - start).round(3)
|
16
|
-
cnt = people.count
|
17
|
-
per_sec = (cnt.to_f / secs).round(2)
|
13
|
+
log(:info) { 'Going to get all the people via API' }
|
18
14
|
|
19
|
-
|
20
|
-
|
21
|
-
|
15
|
+
start = Time.now
|
16
|
+
session.batch.get_people.tap do |people|
|
17
|
+
secs = (Time.now - start).round(3)
|
18
|
+
cnt = people.count
|
19
|
+
per_sec = (cnt.to_f / secs).round(2)
|
22
20
|
|
23
|
-
|
21
|
+
log(:info) {
|
22
|
+
"Loaded #{cnt} people in #{secs} seconds (#{per_sec} people/sec)"
|
23
|
+
}
|
24
24
|
|
25
|
-
|
26
|
-
|
27
|
-
}
|
25
|
+
if modifier.include?(:save)
|
26
|
+
file = file_manager.save_json(people, filename, :timestamp)
|
28
27
|
|
29
|
-
|
28
|
+
log(:info) {
|
29
|
+
"#{people.length} people loaded and saved locally to #{file}."
|
30
|
+
}
|
31
|
+
end
|
32
|
+
end.then do |people|
|
33
|
+
Eco::API::Organization::People.new(people)
|
34
|
+
end
|
30
35
|
end
|
31
36
|
end
|
32
37
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Eco
|
2
|
+
module API
|
3
|
+
class MicroCases
|
4
|
+
module People
|
5
|
+
module Manage
|
6
|
+
module Filename
|
7
|
+
private
|
8
|
+
|
9
|
+
# Spot the source data file.
|
10
|
+
def people_filename(filename = enviro.config.people.cache, newest: false)
|
11
|
+
if newest
|
12
|
+
# search input file based on pattern (in case the name has a timestamp)
|
13
|
+
file_manager.dir.newest_file(file: filename).tap do |file|
|
14
|
+
next unless file
|
15
|
+
|
16
|
+
log(:info) {
|
17
|
+
"previous file found: #{file}"
|
18
|
+
}
|
19
|
+
end
|
20
|
+
else
|
21
|
+
file_manager.dir.file(filename, should_exist: true)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -22,19 +22,10 @@ module Eco
|
|
22
22
|
modifier = [modifier].flatten
|
23
23
|
load_file = %i[file newest].any? {|flag| modifier.include?(flag)}
|
24
24
|
|
25
|
-
|
26
|
-
|
27
|
-
|
25
|
+
if filename && load_file
|
26
|
+
load_cache(filename, newest: modifier.include?(:newest)).tap do |people|
|
27
|
+
next if people.is_a?(Eco::API::Organization::People)
|
28
28
|
|
29
|
-
if file
|
30
|
-
file_manager.load_json(file).tap do |people|
|
31
|
-
next unless people.is_a?(Array)
|
32
|
-
|
33
|
-
log(:info) {
|
34
|
-
"#{people&.length} people loaded from file #{file}"
|
35
|
-
}
|
36
|
-
end
|
37
|
-
else
|
38
29
|
log(:error) {
|
39
30
|
"could not find the file #{file_manager.dir.file(filename)}"
|
40
31
|
}
|
@@ -43,43 +34,10 @@ module Eco
|
|
43
34
|
|
44
35
|
people_load(modifier: modifier - %i[newest file])
|
45
36
|
end
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
start = Time.now
|
50
|
-
session.batch.get_people.tap do |people|
|
51
|
-
secs = (Time.now - start).round(3)
|
52
|
-
cnt = people.count
|
53
|
-
per_sec = (cnt.to_f / secs).round(2)
|
54
|
-
|
55
|
-
log(:info) {
|
56
|
-
"Loaded #{cnt} people in #{secs} seconds (#{per_sec} people/sec)"
|
57
|
-
}
|
58
|
-
|
59
|
-
if modifier.include?(:save) && people && people.length.positive?
|
60
|
-
file = file_manager.save_json(people, filename, :timestamp)
|
61
|
-
log(:info) { "#{people.length} people saved to file #{file}." }
|
62
|
-
end
|
63
|
-
end
|
37
|
+
elsif modifier.include?(:api)
|
38
|
+
people_cache(filename, modifier: modifier)
|
64
39
|
end.then do |people|
|
65
|
-
Eco::API::Organization::People.new(people)
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
private
|
70
|
-
|
71
|
-
def people_load_filename(filename, newest: false)
|
72
|
-
if newest
|
73
|
-
# search input file based on pattern (in case the name has a timestamp)
|
74
|
-
file_manager.dir.newest_file(file: filename).tap do |file|
|
75
|
-
next unless file
|
76
|
-
|
77
|
-
log(:info) {
|
78
|
-
"previous file found: #{file}"
|
79
|
-
}
|
80
|
-
end
|
81
|
-
else
|
82
|
-
file_manager.dir.file(filename, should_exist: true)
|
40
|
+
Eco::API::Organization::People.new(people.to_a)
|
83
41
|
end
|
84
42
|
end
|
85
43
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Eco
|
2
|
+
module API
|
3
|
+
class MicroCases
|
4
|
+
module People
|
5
|
+
module Manage
|
6
|
+
module LoadCache
|
7
|
+
private
|
8
|
+
|
9
|
+
# Finds the source data file and loads it.
|
10
|
+
# @return [Eco::API::Organization::People] the `People` object with the data.
|
11
|
+
def load_cache(filename = enviro.config.people.cache, newest: false)
|
12
|
+
return unless (file = people_filename(filename, newest: newest))
|
13
|
+
|
14
|
+
file_manager.load_json(file).then do |people|
|
15
|
+
next unless people.is_a?(Array)
|
16
|
+
|
17
|
+
log(:info) {
|
18
|
+
"#{people&.length} people loaded from file #{file}"
|
19
|
+
}
|
20
|
+
|
21
|
+
Eco::API::Organization::People.new(people)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -5,16 +5,18 @@ module Eco
|
|
5
5
|
module Manage
|
6
6
|
module Refresh
|
7
7
|
# Helper to obtain all the elements of `people` anew from the _People Manager_.
|
8
|
+
# @note it does NOT save to a local file.
|
8
9
|
# @note
|
9
|
-
# 1. This helper is normally used to run consecutive usecases,
|
10
|
+
# 1. This helper is normally used to run consecutive usecases,
|
11
|
+
# where data needs refresh.
|
10
12
|
# 2. It only includes new people if they are not dirty (they do not have pending updates)
|
11
13
|
# - This contingency wouldn't be necessary if the server worked perfectly.
|
12
14
|
# @param people [Eco::API::Organization::People] the people that needs refresh.
|
13
15
|
# @param include_created [Boolean] include people created during this session? (will check `:create` batch jobs).
|
14
16
|
# @return [Eco::API::Organization::People] the `People` object with the data.
|
15
17
|
def people_refresh(people:, include_created: true) # rubocop:disable Metrics/AbcSize
|
16
|
-
people = people.newFrom people.
|
17
|
-
|
18
|
+
people = people.newFrom people.reject do |person|
|
19
|
+
person.new? && person.dirty?
|
18
20
|
end
|
19
21
|
|
20
22
|
ini = people.length
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require_relative 'manage/filename'
|
2
|
+
require_relative 'manage/load_cache'
|
1
3
|
require_relative 'manage/cache'
|
2
4
|
require_relative 'manage/load'
|
3
5
|
require_relative 'manage/search'
|
@@ -8,6 +10,8 @@ module Eco
|
|
8
10
|
class MicroCases
|
9
11
|
module People
|
10
12
|
module Manage
|
13
|
+
include Filename
|
14
|
+
include LoadCache
|
11
15
|
include Cache
|
12
16
|
include Load
|
13
17
|
include Search
|
@@ -68,7 +68,13 @@ module Eco
|
|
68
68
|
@path.push(self.id) unless top?
|
69
69
|
|
70
70
|
@nodes = @raw_nodes.map.with_index do |cnode, idx|
|
71
|
-
self.class.new(
|
71
|
+
self.class.new(
|
72
|
+
cnode,
|
73
|
+
depth: depth + 1,
|
74
|
+
path: @path.dup,
|
75
|
+
parent: self,
|
76
|
+
_weight: idx
|
77
|
+
)
|
72
78
|
end
|
73
79
|
|
74
80
|
init_hashes
|
@@ -199,8 +205,9 @@ module Eco
|
|
199
205
|
# @param max_depth [Boolean] up to what level `depth` nodes should be included.
|
200
206
|
# @return [Array[Hash]] where `Hash` is a `node` (i.e. `{"tag" => TAG, "nodes": Array[Hash]}`)
|
201
207
|
def as_json( # rubocop:disable Metrics/AbcSize
|
202
|
-
include_children: true,
|
203
|
-
|
208
|
+
include_children: true,
|
209
|
+
include_archived: true,
|
210
|
+
max_depth: total_depth,
|
204
211
|
&block
|
205
212
|
)
|
206
213
|
max_depth ||= total_depth
|
@@ -230,7 +237,7 @@ module Eco
|
|
230
237
|
depth + 1
|
231
238
|
]
|
232
239
|
node_json = self.class::HEADER.zip(values).to_h
|
233
|
-
node_json[
|
240
|
+
node_json['nodes'] = children_json if include_children
|
234
241
|
node_json = yield(node_json, self) if block_given?
|
235
242
|
node_json
|
236
243
|
end
|
@@ -56,7 +56,7 @@ module Eco
|
|
56
56
|
entries.each_with_index do |entry, i|
|
57
57
|
if (i % 10).zero?
|
58
58
|
percent = i * 100 / entries.length
|
59
|
-
print "Searching: #{percent.round}% (#{i}/#{entries.length} entries)\r"
|
59
|
+
print "Searching in results: #{percent.round}% (#{i}/#{entries.length} entries)\r"
|
60
60
|
$stdout.flush
|
61
61
|
end
|
62
62
|
|
@@ -75,7 +75,7 @@ module Eco
|
|
75
75
|
unless email.empty?
|
76
76
|
people_matching = get(
|
77
77
|
params: params.merge(q: email),
|
78
|
-
silent:
|
78
|
+
silent: true,
|
79
79
|
options: options
|
80
80
|
).select do |person|
|
81
81
|
person.email == email
|
@@ -94,7 +94,7 @@ module Eco
|
|
94
94
|
|
95
95
|
private
|
96
96
|
|
97
|
-
def get(params: {}, silent:
|
97
|
+
def get(params: {}, silent: true, options: self.options)
|
98
98
|
msg = 'cannot batch get without api connnection, '
|
99
99
|
msg << 'please provide a valid api connection!'
|
100
100
|
fatal msg unless (people_api = api&.people)
|
@@ -3,69 +3,72 @@ module Eco
|
|
3
3
|
class Session
|
4
4
|
class Config
|
5
5
|
class People < BaseConfig
|
6
|
-
|
7
6
|
def cache=(file)
|
8
|
-
self[
|
7
|
+
self['cache'] = file
|
9
8
|
end
|
10
9
|
|
11
10
|
def cache
|
12
|
-
self[
|
11
|
+
self['cache'] ||= 'cache/people.json'
|
13
12
|
end
|
14
13
|
|
15
14
|
def partial_cache
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
15
|
+
return unless (file = self.cache)
|
16
|
+
|
17
|
+
extension = File.extname(file)
|
18
|
+
basename = File.basename(file, extension)
|
19
|
+
|
20
|
+
File.join(
|
21
|
+
File.dirname(file),
|
22
|
+
"#{basename}_partial#{extension}"
|
23
|
+
)
|
21
24
|
end
|
22
25
|
|
23
26
|
# specifies if people search should be strict or not
|
24
27
|
def strict_search=(value)
|
25
|
-
self[
|
28
|
+
self['strict_search'] = !!value
|
26
29
|
end
|
27
30
|
|
28
31
|
def strict_search?
|
29
|
-
self[
|
32
|
+
self['strict_search']
|
30
33
|
end
|
31
34
|
|
32
35
|
# api queried logs
|
33
36
|
def requests_folder=(folder)
|
34
|
-
self[
|
37
|
+
self['requests_folder'] = folder
|
35
38
|
end
|
36
39
|
|
37
40
|
def requests_folder
|
38
|
-
self[
|
41
|
+
self['requests_folder'] ||= 'requests'
|
39
42
|
end
|
40
43
|
|
41
44
|
# people to exclude from update feeds
|
42
45
|
def discarded_file=(file)
|
43
|
-
self[
|
46
|
+
self['discarded_file'] = file
|
44
47
|
end
|
45
48
|
|
46
49
|
def discarded_file
|
47
|
-
self[
|
50
|
+
self['discarded_file']
|
48
51
|
end
|
49
52
|
|
50
53
|
# with given a person what is the criteria of exclusion
|
51
54
|
def api_excluded(&block)
|
52
|
-
return self[
|
53
|
-
|
55
|
+
return self['api_excluded'] unless block_given?
|
56
|
+
|
57
|
+
self['api_excluded'] = block
|
54
58
|
end
|
55
59
|
|
56
60
|
# internal-external fields map
|
57
61
|
def fields_mapper=(file)
|
58
|
-
self[
|
62
|
+
self['fields_mapper'] = file
|
59
63
|
end
|
60
64
|
|
61
65
|
def fields_mapper
|
62
|
-
self[
|
66
|
+
self['fields_mapper']
|
63
67
|
end
|
64
68
|
|
65
69
|
# person model
|
66
70
|
attr_key :default_usergroup, :default_schema, :default_login_method
|
67
71
|
|
68
|
-
|
69
72
|
def default_usergroup?
|
70
73
|
!!default_usergroup
|
71
74
|
end
|
@@ -80,7 +83,7 @@ module Eco
|
|
80
83
|
|
81
84
|
# @return [Hash] with defined pairs format `key` and Person parsers.
|
82
85
|
def parsers
|
83
|
-
self[
|
86
|
+
self['parsers'] ||= {}
|
84
87
|
end
|
85
88
|
|
86
89
|
# The person parser/serializer for a given format (default `csv`).
|
@@ -1,7 +1,7 @@
|
|
1
1
|
class Eco::API::UseCases::Default::Locations::TagtreeUpload < Eco::API::UseCases::GraphQL::Samples::Location::Command
|
2
2
|
require_relative 'cli/tagtree_upload_cli'
|
3
3
|
|
4
|
-
name
|
4
|
+
name 'tagtree-upload'
|
5
5
|
type :other
|
6
6
|
|
7
7
|
COMMANDS_PER_PAGE = 45
|
@@ -11,10 +11,28 @@ class Eco::API::UseCases::Default::Locations::TagtreeUpload < Eco::API::UseCases
|
|
11
11
|
false
|
12
12
|
end
|
13
13
|
|
14
|
+
def compare_live_with_file?
|
15
|
+
true
|
16
|
+
end
|
17
|
+
|
18
|
+
# # With given the commands, it generates the input of the endpoint mutation.
|
19
|
+
# # @param commands [Array<Hash>]
|
20
|
+
# def input(commands, force_continue: force_continue?)
|
21
|
+
# {
|
22
|
+
# clientMutationId: '',
|
23
|
+
# id: target_structure_id,
|
24
|
+
# force: force_continue,
|
25
|
+
# commands: commands
|
26
|
+
# }
|
27
|
+
# end
|
28
|
+
|
14
29
|
# We only define the `:insert` stage
|
15
30
|
def inputs(force_continue: force_continue?)
|
16
31
|
{}.tap do |stages|
|
17
|
-
stages[:insert] = input(
|
32
|
+
stages[:insert] = input(
|
33
|
+
insert_commands,
|
34
|
+
force_continue: force_continue
|
35
|
+
)
|
18
36
|
end.each do |stage, input|
|
19
37
|
yield(input, stage) if block_given?
|
20
38
|
end
|
@@ -29,16 +29,20 @@ module Eco::API::UseCases::GraphQL::Helpers::Location
|
|
29
29
|
# At any moment we want to know how the live tree is
|
30
30
|
# @note it also does a backup
|
31
31
|
# @return [Eco::API::Organization::TagTree] the latest tree (`current_tree`)
|
32
|
-
def track_current_tree(tree)
|
32
|
+
def track_current_tree(tree) # rubocop:disable Metrics/AbcSize
|
33
|
+
return unless track_current_tree?
|
33
34
|
return if simulate?
|
34
35
|
return if tree.nil?
|
35
36
|
|
36
|
-
|
37
|
-
|
37
|
+
tree_id = current_tree&.id
|
38
|
+
tree_name = current_tree&.name
|
39
|
+
tree_id = tree.id if tree.respond_to?(:id)
|
40
|
+
tree_name = tree.name if tree.respond_to?(:name)
|
41
|
+
latest_tree = tree if tree.is_a?(Eco::API::Organization::TagTree)
|
42
|
+
|
43
|
+
if tree.respond_to?(:treeify)
|
38
44
|
latest_tree ||= Eco::API::Organization::TagTree.new(
|
39
|
-
tree.treeify
|
40
|
-
id: tree.id,
|
41
|
-
name: tree.name
|
45
|
+
tree.treeify
|
42
46
|
)
|
43
47
|
end
|
44
48
|
|
@@ -46,6 +50,9 @@ module Eco::API::UseCases::GraphQL::Helpers::Location
|
|
46
50
|
next unless latest_tree.is_a?(Eco::API::Organization::TagTree)
|
47
51
|
next if latest_tree.empty?
|
48
52
|
|
53
|
+
latest_tree.id = tree_id if latest_tree.id.nil?
|
54
|
+
latest_tree.name = tree_name if latest_tree.name.nil?
|
55
|
+
|
49
56
|
# a backup happens:
|
50
57
|
self.current_tree = latest_tree
|
51
58
|
end
|
@@ -53,7 +60,7 @@ module Eco::API::UseCases::GraphQL::Helpers::Location
|
|
53
60
|
|
54
61
|
# @param tree [Eco::API::Organization::TagTree, Hash, Array]
|
55
62
|
# @return [Boolean] whether or not the backup was created
|
56
|
-
def backup_tree(tree = current_tree || live_tree)
|
63
|
+
def backup_tree(tree = current_tree || live_tree) # rubocop:disable Naming/PredicateMethod
|
57
64
|
return false if simulate?
|
58
65
|
case tree
|
59
66
|
when Eco::API::Organization::TagTree
|
@@ -22,7 +22,7 @@ module Eco::API::UseCases::GraphQL::Helpers::Location
|
|
22
22
|
log(:warn) { msg }
|
23
23
|
|
24
24
|
# a backup happens:
|
25
|
-
return
|
25
|
+
return unless (self.current_tree = session_live_tree)
|
26
26
|
|
27
27
|
@target_structure_id = current_tree.id
|
28
28
|
end
|
@@ -18,7 +18,6 @@ class Eco::API::UseCases::GraphQL::Helpers::Location::Command::Diff
|
|
18
18
|
class_ids = class_ids.compact.map {|val| val.split('|')}.flatten.uniq
|
19
19
|
h['classificationIds'] = class_ids
|
20
20
|
end
|
21
|
-
|
22
21
|
if archive? || insert?
|
23
22
|
# We assume archives do not have `move` nor update `id` or `name`
|
24
23
|
h['nodeId'] = node_id || node_id_prev
|