eco-helpers 3.0.25 → 3.0.27
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 +39 -1
- data/eco-helpers.gemspec +1 -1
- data/lib/eco/api/common/loaders/base.rb +13 -1
- data/lib/eco/api/common/loaders/case_base.rb +1 -1
- data/lib/eco/api/common/loaders/error_handler.rb +1 -1
- data/lib/eco/api/common/loaders/parser.rb +2 -2
- data/lib/eco/api/common/loaders/policy.rb +1 -1
- data/lib/eco/api/common/loaders/use_case.rb +1 -1
- data/lib/eco/api/common/people/default_parsers/archived_parser.rb +19 -0
- data/lib/eco/api/common/people/default_parsers/boolean_parser.rb +4 -4
- data/lib/eco/api/common/people/default_parsers/date_parser.rb +3 -3
- data/lib/eco/api/common/people/default_parsers/freemium_parser.rb +6 -6
- data/lib/eco/api/common/people/default_parsers/login_providers_parser.rb +3 -3
- data/lib/eco/api/common/people/default_parsers/multi_parser.rb +4 -4
- data/lib/eco/api/common/people/default_parsers/policy_groups_parser.rb +9 -6
- data/lib/eco/api/common/people/default_parsers/send_invites_parser.rb +6 -5
- data/lib/eco/api/common/people/default_parsers/xls_parser.rb +2 -2
- data/lib/eco/api/common/people/default_parsers.rb +1 -0
- data/lib/eco/api/common/people/entries.rb +16 -15
- data/lib/eco/api/common/people/person_entry.rb +53 -37
- data/lib/eco/api/common/people/person_parser.rb +8 -6
- data/lib/eco/api/common/session/logger/channels.rb +1 -1
- data/lib/eco/api/common/session/logger.rb +2 -2
- data/lib/eco/api/common/session/mailer/aws_provider.rb +3 -2
- data/lib/eco/api/common/session/mailer/provider_base.rb +6 -2
- data/lib/eco/api/common/session/mailer/sendgrid_provider.rb +9 -9
- data/lib/eco/api/common/session/mailer.rb +8 -3
- data/lib/eco/api/common/session/sftp.rb +2 -2
- data/lib/eco/api/common/version_patches/object.rb +2 -1
- data/lib/eco/api/custom/mailer.rb +1 -1
- data/lib/eco/api/error/handlers.rb +3 -3
- data/lib/eco/api/error.rb +17 -17
- data/lib/eco/api/microcases/people/apply_changes/set_account/account_excluded.rb +3 -11
- data/lib/eco/api/microcases/people/apply_changes/set_core/core_excluded.rb +4 -1
- data/lib/eco/api/microcases/people/manage/search.rb +3 -1
- data/lib/eco/api/organization/people.rb +1 -0
- data/lib/eco/api/policies.rb +2 -2
- data/lib/eco/api/session/batch/job.rb +2 -2
- data/lib/eco/api/session/batch/launcher.rb +4 -5
- data/lib/eco/api/session/batch/searcher.rb +4 -4
- data/lib/eco/api/session/config/api.rb +2 -2
- data/lib/eco/api/session/config/apis/enviro_spaces.rb +3 -3
- data/lib/eco/api/session/config/apis/space_helpers.rb +4 -4
- data/lib/eco/api/session/config/apis.rb +1 -1
- data/lib/eco/api/session/config/post_launch.rb +7 -4
- data/lib/eco/api/session/config/sftp.rb +1 -1
- data/lib/eco/api/session/config/tagtree.rb +1 -1
- data/lib/eco/api/session/config/workflow.rb +4 -4
- data/lib/eco/api/session/config.rb +25 -24
- data/lib/eco/api/session.rb +4 -4
- data/lib/eco/api/usecases/base_io/validations.rb +4 -3
- data/lib/eco/api/usecases/cli/option.rb +5 -2
- data/lib/eco/api/usecases/default/people/amend/clear_abilities_case.rb +2 -2
- data/lib/eco/api/usecases/default/people/amend/restore_db_case.rb +16 -9
- data/lib/eco/api/usecases/default/people/treat/analyse_people_case.rb +20 -20
- data/lib/eco/api/usecases/default.rb +5 -5
- data/lib/eco/api/usecases/default_cases/to_csv_case.rb +8 -8
- data/lib/eco/api/usecases/default_cases/upsert_case.rb +4 -4
- data/lib/eco/api/usecases/graphql/helpers/base.rb +1 -1
- data/lib/eco/api/usecases/graphql/helpers/location/base/tree_tracking.rb +5 -1
- data/lib/eco/api/usecases/graphql/helpers/location/command/diffs/stages/commandable.rb +2 -1
- data/lib/eco/api/usecases/graphql/helpers/location/command/result.rb +3 -3
- data/lib/eco/api/usecases/graphql/helpers/location/command.rb +3 -0
- data/lib/eco/api/usecases/graphql/samples/location/command/dsl.rb +2 -2
- data/lib/eco/api/usecases/graphql/samples/location/command/service/tree_update.rb +9 -3
- data/lib/eco/api/usecases/graphql/samples/location/service/tree_diff/convertible/inputable.rb +5 -4
- data/lib/eco/api/usecases/graphql/samples/location/service/tree_diff/convertible/parsing.rb +5 -2
- data/lib/eco/api/usecases/graphql/samples/location/service/tree_diff.rb +3 -3
- data/lib/eco/api/usecases/graphql/utils/sftp.rb +1 -1
- data/lib/eco/api/usecases/lib/{file_pattern.rb → files/file_pattern.rb} +5 -1
- data/lib/eco/api/usecases/lib/{sftp.rb → files/sftp.rb} +27 -16
- data/lib/eco/api/usecases/lib/files.rb +7 -0
- data/lib/eco/api/usecases/lib.rb +1 -2
- data/lib/eco/api/usecases/ooze_cases/export_register_case.rb +5 -5
- data/lib/eco/api/usecases/ooze_samples/helpers/exportable_ooze.rb +14 -11
- data/lib/eco/api/usecases/ooze_samples/helpers_migration/copying.rb +14 -23
- data/lib/eco/api/usecases/ooze_samples/helpers_migration/typed_fields_pairing.rb +49 -27
- data/lib/eco/api/usecases/ooze_samples/ooze_base_case.rb +9 -9
- data/lib/eco/api/usecases/ooze_samples/ooze_run_base_case.rb +1 -1
- data/lib/eco/api/usecases/ooze_samples/register_export_case.rb +25 -17
- data/lib/eco/api/usecases/ooze_samples/register_migration_case.rb +41 -24
- data/lib/eco/api/usecases/ooze_samples/register_update_case.rb +16 -15
- data/lib/eco/api/usecases/samples/drivers/cli/sftp_cli.rb +15 -15
- data/lib/eco/api/usecases/samples/drivers/cli/url_pull_cli.rb +5 -5
- data/lib/eco/api/usecases/samples/drivers/sftp_sample.rb +2 -2
- data/lib/eco/api/usecases/use_case.rb +6 -6
- data/lib/eco/api/usecases/use_case_chain/chaining.rb +6 -6
- data/lib/eco/api/usecases/use_case_chain.rb +4 -4
- data/lib/eco/api/usecases/use_case_io.rb +2 -1
- data/lib/eco/api/usecases.rb +9 -9
- data/lib/eco/cli/config/options_set.rb +4 -4
- data/lib/eco/cli/config/use_cases.rb +3 -3
- data/lib/eco/cli/scripting/argument.rb +1 -1
- data/lib/eco/cli_default/input.rb +9 -9
- data/lib/eco/cli_default/options.rb +125 -100
- data/lib/eco/cli_default/people.rb +3 -3
- data/lib/eco/cli_default/usecases.rb +83 -83
- data/lib/eco/cli_default/workflow.rb +7 -7
- data/lib/eco/data/files/helpers.rb +3 -3
- data/lib/eco/data/fuzzy_match/result.rb +69 -26
- data/lib/eco/data/fuzzy_match/results.rb +10 -10
- data/lib/eco/data/fuzzy_match/score.rb +13 -8
- data/lib/eco/data/fuzzy_match.rb +65 -48
- data/lib/eco/data/locations/node_base/treeify.rb +13 -11
- data/lib/eco/data/mapper.rb +4 -4
- data/lib/eco/language/auxiliar_logger.rb +4 -4
- data/lib/eco/language/delegation/const_delegator.rb +64 -0
- data/lib/eco/language/delegation/const_lookup_hooks.rb +81 -0
- data/lib/eco/language/delegation/delegated_class.rb +84 -0
- data/lib/eco/language/delegation.rb +8 -0
- data/lib/eco/language/klass/when_inherited.rb +1 -0
- data/lib/eco/language/methods/delegate_missing.rb +1 -0
- data/lib/eco/language/models/class_helpers.rb +25 -23
- data/lib/eco/language/models/collection.rb +12 -2
- data/lib/eco/language.rb +1 -0
- data/lib/eco/version.rb +1 -1
- metadata +12 -6
@@ -1,5 +1,5 @@
|
|
1
1
|
class Eco::API::UseCases::Default::People::Treat::Analyse < Eco::API::Common::Loaders::UseCase
|
2
|
-
name
|
2
|
+
name 'analyse-people'
|
3
3
|
type :export
|
4
4
|
|
5
5
|
require_relative 'cli/analyse_people_cli'
|
@@ -12,7 +12,7 @@ class Eco::API::UseCases::Default::People::Treat::Analyse < Eco::API::Common::Lo
|
|
12
12
|
elsif case_options[:identify_unnamed]
|
13
13
|
identify_unnamed
|
14
14
|
else
|
15
|
-
log(:info) {
|
15
|
+
log(:info) { 'No analysis operation was specified' }
|
16
16
|
end.tap do |people_involved|
|
17
17
|
next unless people_involved
|
18
18
|
|
@@ -27,7 +27,7 @@ class Eco::API::UseCases::Default::People::Treat::Analyse < Eco::API::Common::Lo
|
|
27
27
|
similarity_analytics.unnamed.tap do |unnamed|
|
28
28
|
next unless unnamed.empty?
|
29
29
|
|
30
|
-
log(:info) {
|
30
|
+
log(:info) { 'There were no people with no name!!' }
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
@@ -35,13 +35,13 @@ class Eco::API::UseCases::Default::People::Treat::Analyse < Eco::API::Common::Lo
|
|
35
35
|
analysed = similarity_screening
|
36
36
|
|
37
37
|
if case_options[:ignore_matching_words]
|
38
|
-
log(:info) {
|
38
|
+
log(:info) { 'Fine tune results by ignoring matching words...' }
|
39
39
|
analysed = strict_similarity(analysed)
|
40
40
|
end
|
41
41
|
|
42
42
|
similarity_analytics.newSimilarity(analysed).tap do |related_people|
|
43
43
|
if related_people.empty?
|
44
|
-
log(:info) {
|
44
|
+
log(:info) { 'There were no possible duplicates identified!!' }
|
45
45
|
else
|
46
46
|
report = similarity_analytics.report(analysed, format: :txt)
|
47
47
|
save!(report)
|
@@ -157,23 +157,23 @@ class Eco::API::UseCases::Default::People::Treat::Analyse < Eco::API::Common::Lo
|
|
157
157
|
end
|
158
158
|
|
159
159
|
def output_file
|
160
|
-
@output_file ||= options.dig(:output, :file) ||
|
160
|
+
@output_file ||= options.dig(:output, :file) || 'analytics.txt'
|
161
161
|
end
|
162
162
|
|
163
163
|
def save!(data)
|
164
|
-
ext = File.extname(output_file).downcase.delete(
|
164
|
+
ext = File.extname(output_file).downcase.delete('.')
|
165
165
|
|
166
166
|
log(:info) { "Generating file '#{output_file}'" }
|
167
167
|
|
168
|
-
File.open(output_file,
|
168
|
+
File.open(output_file, 'w') do |fd|
|
169
169
|
case ext
|
170
|
-
when
|
170
|
+
when 'txt'
|
171
171
|
fd << data
|
172
|
-
when
|
173
|
-
puts
|
172
|
+
when 'html'
|
173
|
+
puts 'html is still not supported'
|
174
174
|
exit(1)
|
175
|
-
when
|
176
|
-
puts
|
175
|
+
when 'json'
|
176
|
+
puts 'json is still not supported'
|
177
177
|
exit(1)
|
178
178
|
end
|
179
179
|
end
|
@@ -182,11 +182,11 @@ class Eco::API::UseCases::Default::People::Treat::Analyse < Eco::API::Common::Lo
|
|
182
182
|
# A way to use command line to specify part
|
183
183
|
# => i.e. details[first-name] AND details[surname]
|
184
184
|
def proc_value_access(expression)
|
185
|
-
#return expression.to_sym if expression.start_with?(
|
186
|
-
subexpressions = expression.split(
|
185
|
+
#return expression.to_sym if expression.start_with?(':')
|
186
|
+
subexpressions = expression.split(' AND ')
|
187
187
|
proc do |person|
|
188
188
|
values = subexpressions.map {|exp| attribute_access(person, exp)}
|
189
|
-
values.compact.join(
|
189
|
+
values.compact.join(' ')
|
190
190
|
end
|
191
191
|
end
|
192
192
|
|
@@ -216,9 +216,9 @@ class Eco::API::UseCases::Default::People::Treat::Analyse < Eco::API::Common::Lo
|
|
216
216
|
|
217
217
|
is_method = part.is_a?(Symbol) || obj.respond_to?(part.to_sym)
|
218
218
|
return obj.send(part.to_sym) if is_method
|
219
|
-
return get_attr(obj, part[1..]) if part.start_with?(
|
219
|
+
return get_attr(obj, part[1..]) if part.start_with?(':')
|
220
220
|
|
221
|
-
if part.start_with?(
|
221
|
+
if part.start_with?('details[')
|
222
222
|
via_details = obj.respond_to?(:details) && (details = obj.details)
|
223
223
|
return unless via_details
|
224
224
|
|
@@ -228,11 +228,11 @@ class Eco::API::UseCases::Default::People::Treat::Analyse < Eco::API::Common::Lo
|
|
228
228
|
raise "Review your -use-field expression. It should read: person.details[target-alt_id]"
|
229
229
|
end
|
230
230
|
|
231
|
-
if part.start_with?(
|
231
|
+
if part.start_with?('account')
|
232
232
|
return obj.respond_to?(:account) ? obj.account : nil
|
233
233
|
end
|
234
234
|
|
235
|
-
return obj if part.start_with?(
|
235
|
+
return obj if part.start_with?('person')
|
236
236
|
|
237
237
|
raise "Review your expression. Cannot recognize '#{part}' as part of '#{obj.class}'"
|
238
238
|
end
|
@@ -2,11 +2,11 @@ module Eco
|
|
2
2
|
module API
|
3
3
|
class UseCases
|
4
4
|
class Default < Eco::API::UseCases
|
5
|
-
# autoloads_children_of
|
6
|
-
# autoload_namespace
|
7
|
-
# autoload_namespace
|
8
|
-
# autoload_namespace
|
9
|
-
# autoload_namespace
|
5
|
+
# autoloads_children_of 'Eco::API::Common::Loaders::UseCase'
|
6
|
+
# autoload_namespace 'Eco::API::UseCases::Default'
|
7
|
+
# autoload_namespace 'Eco::API::UseCases::DefaultCases'
|
8
|
+
# autoload_namespace 'Eco::API::UseCases::OozeCases'
|
9
|
+
# autoload_namespace 'Eco::API::UseCases::GraphQL::Cases'
|
10
10
|
end
|
11
11
|
end
|
12
12
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
class Eco::API::UseCases::DefaultCases::ToCsvCase < Eco::API::Common::Loaders::UseCase
|
2
|
-
name
|
2
|
+
name 'to-csv'
|
3
3
|
type :export
|
4
4
|
|
5
5
|
OUT_FILENAME = 'pm'.freeze
|
@@ -8,14 +8,14 @@ class Eco::API::UseCases::DefaultCases::ToCsvCase < Eco::API::Common::Loaders::U
|
|
8
8
|
options[:end_get] = false
|
9
9
|
|
10
10
|
unless people && !people.empty?
|
11
|
-
log(:warn) {
|
11
|
+
log(:warn) { 'No source people to create the file... aborting!' }
|
12
12
|
return false
|
13
13
|
end
|
14
14
|
|
15
15
|
if options.dig(:export, :options, :split_schemas)
|
16
16
|
by_schema.each do |id, people|
|
17
17
|
sch_name = schemas.to_name(id)
|
18
|
-
prefix = sch_name ? sch_name.gsub(
|
18
|
+
prefix = sch_name ? sch_name.gsub(' ', '_').downcase : 'no_schema'
|
19
19
|
filename = in_folder("#{prefix}_#{File.basename(file)}")
|
20
20
|
create_file!(filename, people)
|
21
21
|
end
|
@@ -29,7 +29,7 @@ class Eco::API::UseCases::DefaultCases::ToCsvCase < Eco::API::Common::Loaders::U
|
|
29
29
|
def create_file!(filename = file, data = people)
|
30
30
|
session.log(:info) { "going to create file: #{filename}" }
|
31
31
|
|
32
|
-
CSV.open(filename,
|
32
|
+
CSV.open(filename, 'w') do |csv|
|
33
33
|
csv << spot_header(data.first)
|
34
34
|
data.each do |person|
|
35
35
|
csv << to_row(person)
|
@@ -40,13 +40,13 @@ class Eco::API::UseCases::DefaultCases::ToCsvCase < Eco::API::Common::Loaders::U
|
|
40
40
|
def to_row(person)
|
41
41
|
entry = to_entry_type(person)
|
42
42
|
entry.values_at(*keys(entry)).tap do |row|
|
43
|
-
row << (schemas.to_name(person.details&.schema_id) ||
|
43
|
+
row << (schemas.to_name(person.details&.schema_id) || 'No Schema')
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
47
|
def spot_header(person = people.first)
|
48
48
|
header = keys(to_entry_type(person))
|
49
|
-
header <<
|
49
|
+
header << 'Schema'
|
50
50
|
header = yield(header) if block_given?
|
51
51
|
header = nice_header_names(header, schema: schema(person.details)) if nice_header_names?
|
52
52
|
header
|
@@ -73,14 +73,14 @@ class Eco::API::UseCases::DefaultCases::ToCsvCase < Eco::API::Common::Loaders::U
|
|
73
73
|
end
|
74
74
|
|
75
75
|
def deps
|
76
|
-
@deps ||= {
|
76
|
+
@deps ||= {'supervisor_id' => {people: people}}
|
77
77
|
end
|
78
78
|
|
79
79
|
def file
|
80
80
|
@file ||= out_filename.tap do |filename|
|
81
81
|
next if filename
|
82
82
|
|
83
|
-
log(:error) {
|
83
|
+
log(:error) { 'Destination file not specified' }
|
84
84
|
return false
|
85
85
|
end
|
86
86
|
end
|
@@ -1,12 +1,12 @@
|
|
1
1
|
class Eco::API::UseCases::DefaultCases::UpsertCase < Eco::API::Common::Loaders::UseCase
|
2
|
-
name
|
2
|
+
name 'upsert'
|
3
3
|
type :sync
|
4
4
|
|
5
5
|
def main(entries, people, session, options, usecase)
|
6
6
|
micro = session.micro
|
7
|
-
creation = session.new_job(
|
8
|
-
update = session.new_job(
|
9
|
-
supers = session.new_job(
|
7
|
+
creation = session.new_job('main', 'create', :create, usecase)
|
8
|
+
update = session.new_job('main', 'update', :update, usecase)
|
9
|
+
supers = session.new_job('post', 'supers', :update, usecase, :core)
|
10
10
|
|
11
11
|
micro.with_each(entries, people, options, append_created: append_created) do |entry, person|
|
12
12
|
person.new? ? creation.add(person) : update.add(person)
|
@@ -11,7 +11,7 @@ module Eco::API::UseCases::GraphQL::Helpers
|
|
11
11
|
|
12
12
|
# Keep a copy of the requests/responses for future reference
|
13
13
|
def backup(data, type:)
|
14
|
-
dry_run = simulate? ?
|
14
|
+
dry_run = simulate? ? '_dry_run' : ''
|
15
15
|
dir = config.people.requests_folder
|
16
16
|
file = File.join(dir, "#{type}#{dry_run}.json")
|
17
17
|
session.file_manager.save_json(data, file, :timestamp)
|
@@ -35,7 +35,11 @@ module Eco::API::UseCases::GraphQL::Helpers::Location
|
|
35
35
|
|
36
36
|
latest_tree = tree if tree.is_a?(Eco::API::Organization::TagTree)
|
37
37
|
if tree.respond_to?(:treeify) && track_current_tree?
|
38
|
-
latest_tree ||= Eco::API::Organization::TagTree.new(
|
38
|
+
latest_tree ||= Eco::API::Organization::TagTree.new(
|
39
|
+
tree.treeify,
|
40
|
+
id: tree.id,
|
41
|
+
name: tree.name
|
42
|
+
)
|
39
43
|
end
|
40
44
|
|
41
45
|
latest_tree.tap do
|
@@ -37,7 +37,8 @@ class Eco::API::UseCases::GraphQL::Helpers::Location::Command::Diffs
|
|
37
37
|
end
|
38
38
|
|
39
39
|
def stage_diffs(stage)
|
40
|
-
|
40
|
+
msg = "There is NO support for stage '#{stage}'. Please review"
|
41
|
+
raise ArgumentError, msg unless respond_to?(stage)
|
41
42
|
|
42
43
|
sort_diffs(stage) do
|
43
44
|
send(stage)
|
@@ -60,13 +60,13 @@ module Eco::API::UseCases::GraphQL::Helpers::Location::Command
|
|
60
60
|
def command_id
|
61
61
|
return unless result
|
62
62
|
|
63
|
-
command_result[
|
63
|
+
command_result['id']
|
64
64
|
end
|
65
65
|
|
66
66
|
def as_json
|
67
67
|
{
|
68
|
-
|
69
|
-
|
68
|
+
'request' => input,
|
69
|
+
'response' => result.doc
|
70
70
|
}
|
71
71
|
end
|
72
72
|
end
|
@@ -72,13 +72,16 @@ module Eco::API::UseCases::GraphQL::Helpers::Location
|
|
72
72
|
pages = (total.to_f / size).ceil.to_i
|
73
73
|
page = 1
|
74
74
|
out = []
|
75
|
+
|
75
76
|
comms.each_slice(size) do |comms_slice|
|
76
77
|
sliced_input = input_data.slice(:clientMutationId, :id).merge(commands: comms_slice)
|
78
|
+
|
77
79
|
yield(sliced_input, page, pages, comms_slice.count, total).tap do |response|
|
78
80
|
out.push([sliced_input, response])
|
79
81
|
page += 1
|
80
82
|
end
|
81
83
|
end
|
84
|
+
|
82
85
|
out
|
83
86
|
end
|
84
87
|
end
|
@@ -17,8 +17,8 @@ class Eco::API::UseCases::GraphQL::Samples::Location
|
|
17
17
|
# end
|
18
18
|
# end
|
19
19
|
def inputs(*_args, force_continue: force_continue?, **_kargs, &_block) # rubocop:disable Lint/UnusedMethodArgument
|
20
|
-
msg = "You should implement this method in your child class.\n
|
21
|
-
msg <<
|
20
|
+
msg = "You should implement this method in your child class.\n'
|
21
|
+
msg << 'Which should yield the input Hash and the stage or descriptor."
|
22
22
|
raise Eco::API::UseCases::GraphQL::Base::NotImplementedMethod, msg
|
23
23
|
end
|
24
24
|
|
@@ -8,6 +8,7 @@ class Eco::API::UseCases::GraphQL::Samples::Location
|
|
8
8
|
class << self
|
9
9
|
def included(base)
|
10
10
|
super
|
11
|
+
|
11
12
|
base.send :include, Eco::API::UseCases::GraphQL::Samples::Location::Service::TreeDiff
|
12
13
|
base.send :include, Eco::API::UseCases::GraphQL::Samples::Location::Command::DSL
|
13
14
|
base.send :include, Eco::API::UseCases::GraphQL::Utils::Sftp
|
@@ -40,7 +41,11 @@ class Eco::API::UseCases::GraphQL::Samples::Location
|
|
40
41
|
original_tree: current_tree,
|
41
42
|
logger: logger
|
42
43
|
).tap do |nodes_diff|
|
43
|
-
archive_input = input(
|
44
|
+
archive_input = input(
|
45
|
+
nodes_diff.stage_commands(:archive),
|
46
|
+
force_continue: true
|
47
|
+
)
|
48
|
+
|
44
49
|
sliced_batches(
|
45
50
|
archive_input,
|
46
51
|
desc: stage,
|
@@ -48,6 +53,7 @@ class Eco::API::UseCases::GraphQL::Samples::Location
|
|
48
53
|
) do |sliced_input, response, page, pages, count, total| # rubocop:disable Metrics/ParameterLists
|
49
54
|
page_results = request_results_class.new(sliced_input, response)
|
50
55
|
(results[stage] ||= []) << page_results
|
56
|
+
|
51
57
|
self.error ||= page_errors?(page_results, page, pages, count, total, stage: stage)
|
52
58
|
end
|
53
59
|
end
|
@@ -89,8 +95,8 @@ class Eco::API::UseCases::GraphQL::Samples::Location
|
|
89
95
|
return if options.dig(:workflow, :no_email)
|
90
96
|
|
91
97
|
digest_msgs = logger.cache.logs(level: %i[info error warn])
|
92
|
-
str_exception = exception ?
|
93
|
-
str_exception =
|
98
|
+
str_exception = exception ? ' - Exception!' : ''
|
99
|
+
str_exception = ' - Aborted!' if exiting?
|
94
100
|
|
95
101
|
subject = "#{config.active_enviro} - #{title}#{str_exception}"
|
96
102
|
|
data/lib/eco/api/usecases/graphql/samples/location/service/tree_diff/convertible/inputable.rb
CHANGED
@@ -4,14 +4,15 @@ module Eco::API::UseCases::GraphQL::Samples::Location::Service
|
|
4
4
|
module Inputable
|
5
5
|
class << self
|
6
6
|
def included(base)
|
7
|
-
super
|
7
|
+
super
|
8
|
+
|
8
9
|
base.send :include, Eco::Data::Files
|
9
10
|
end
|
10
11
|
end
|
11
12
|
|
12
13
|
include Eco::API::UseCases::GraphQL::Helpers::Base::CaseEnv
|
13
14
|
|
14
|
-
IN_FILENAME = /requested_tree\.csv
|
15
|
+
IN_FILENAME = /requested_tree\.csv/
|
15
16
|
IN_FOLDER = 'sftp'.freeze
|
16
17
|
|
17
18
|
private
|
@@ -25,7 +26,7 @@ module Eco::API::UseCases::GraphQL::Samples::Location::Service
|
|
25
26
|
if file
|
26
27
|
log(:info) { "Using input file '#{file}'" }
|
27
28
|
else
|
28
|
-
log(:warn) {
|
29
|
+
log(:warn) { 'Could not find any input file' }
|
29
30
|
exit(1)
|
30
31
|
end
|
31
32
|
end
|
@@ -45,7 +46,7 @@ module Eco::API::UseCases::GraphQL::Samples::Location::Service
|
|
45
46
|
end
|
46
47
|
|
47
48
|
def input_folder
|
48
|
-
|
49
|
+
File.join(config.active_enviro, self.class::IN_FOLDER)
|
49
50
|
end
|
50
51
|
end
|
51
52
|
end
|
@@ -26,18 +26,21 @@ module Eco::API::UseCases::GraphQL::Samples::Location::Service
|
|
26
26
|
row_transform&.call(row)
|
27
27
|
transform_classifications(row)
|
28
28
|
end
|
29
|
+
|
29
30
|
csv
|
30
31
|
end
|
31
32
|
|
32
33
|
# The user define block for row transformation
|
33
34
|
def custom_input_row_transform_block
|
34
|
-
return
|
35
|
+
return unless respond_to?(:custom_input_row_transform, true)
|
36
|
+
|
35
37
|
method(:custom_input_row_transform)
|
36
38
|
end
|
37
39
|
|
38
40
|
# The user define block for row transformation
|
39
41
|
def custom_input_csv_transform_block
|
40
|
-
return
|
42
|
+
return unless respond_to?(:custom_input_csv_transform, true)
|
43
|
+
|
41
44
|
method(:custom_input_csv_transform)
|
42
45
|
end
|
43
46
|
end
|
@@ -5,11 +5,11 @@ module Eco::API::UseCases::GraphQL::Samples
|
|
5
5
|
# class Custom::UseCase::TagtreeDiff < Eco::API::UseCases::GraphQL::Samples::Location
|
6
6
|
# name 'tagtree-diff'
|
7
7
|
# type :other
|
8
|
-
|
8
|
+
#
|
9
9
|
# require_relative 'cli/10_tagtree_diff_cli'
|
10
|
-
|
10
|
+
#
|
11
11
|
# include Eco::API::UseCases::GraphQL::Samples::Location::Service::TreeDiff
|
12
|
-
|
12
|
+
#
|
13
13
|
# IN_FILENAME = /requested_tree\.csv/.freeze
|
14
14
|
# IN_FOLDER = 'sftp'.freeze
|
15
15
|
# HEADER_MAPS = {
|
@@ -1,4 +1,4 @@
|
|
1
|
-
module Eco::API::UseCases::Lib
|
1
|
+
module Eco::API::UseCases::Lib::Files
|
2
2
|
module FilePattern
|
3
3
|
class WrongConst < ArgumentError; end
|
4
4
|
|
@@ -29,6 +29,10 @@ module Eco::API::UseCases::Lib
|
|
29
29
|
rescue NameError
|
30
30
|
self.class.const_get(fpc)
|
31
31
|
end
|
32
|
+
elsif respond_to?(:file_pattern, true)
|
33
|
+
file_pattern
|
34
|
+
elsif self.class.const_defined?(:FILE_PATTERN)
|
35
|
+
self.class::FILE_PATTERN
|
32
36
|
end
|
33
37
|
rescue NameError
|
34
38
|
raise WrongConst, "(#{self.class}) Unknown constant: #{fpc}"
|
@@ -1,4 +1,4 @@
|
|
1
|
-
module Eco::API::UseCases::Lib
|
1
|
+
module Eco::API::UseCases::Lib::Files
|
2
2
|
module Sftp
|
3
3
|
class UnspecifiedRemoteFolder < ArgumentError; end
|
4
4
|
|
@@ -18,10 +18,15 @@ module Eco::API::UseCases::Lib
|
|
18
18
|
alias_method :sftp_upload, :upload
|
19
19
|
|
20
20
|
def sftp_group_id
|
21
|
-
if
|
22
|
-
|
23
|
-
|
21
|
+
return super if defined?(super) && !super.nil?
|
22
|
+
return group_id if respond_to?(:group_id, true)
|
23
|
+
|
24
|
+
if (group_id = options.dig(:sftp, :group))
|
24
25
|
group_id
|
26
|
+
elsif self.class.const_defined?(:SFTP_GROUP)
|
27
|
+
self.class.const_get(:SFTP_GROUP)
|
28
|
+
elsif self.class.const_defined?(:GROUP_ID)
|
29
|
+
self.class.const_get(:GROUP_ID)
|
25
30
|
end
|
26
31
|
end
|
27
32
|
|
@@ -78,7 +83,7 @@ module Eco::API::UseCases::Lib
|
|
78
83
|
sftp_archive_file!(filename)
|
79
84
|
end
|
80
85
|
|
81
|
-
def ensure_remote_empty(subfolder: remote_subfolder, pattern: nil)
|
86
|
+
def ensure_remote_empty(subfolder: remote_subfolder, pattern: nil, timeout: 3)
|
82
87
|
files = with_remote_files(subfolder: subfolder, pattern: pattern)
|
83
88
|
return if files.empty?
|
84
89
|
|
@@ -92,7 +97,7 @@ module Eco::API::UseCases::Lib
|
|
92
97
|
'Do you want to proceed to delete? (Y/n):',
|
93
98
|
explanation: msg,
|
94
99
|
default: 'Y',
|
95
|
-
timeout:
|
100
|
+
timeout: timeout
|
96
101
|
) do |response|
|
97
102
|
next unless response.upcase.start_with?('Y')
|
98
103
|
|
@@ -106,6 +111,18 @@ module Eco::API::UseCases::Lib
|
|
106
111
|
end
|
107
112
|
end
|
108
113
|
|
114
|
+
def local_folder
|
115
|
+
return super if defined?(super) && !super.nil?
|
116
|
+
|
117
|
+
if (local_dir = options.dig(:sftp, :local_folder))
|
118
|
+
local_dir
|
119
|
+
elsif self.class.const_defined?(:LOCAL_FOLDER)
|
120
|
+
self.class::LOCAL_FOLDER
|
121
|
+
else
|
122
|
+
'.'
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
109
126
|
def to_remote_path(file, subfolder: remote_subfolder)
|
110
127
|
[remote_folder(subfolder), file].join('/')
|
111
128
|
end
|
@@ -113,6 +130,8 @@ module Eco::API::UseCases::Lib
|
|
113
130
|
# `remote_target_folder` overrides `sftp_config.remote_folder` as well as `remote_subfolder`
|
114
131
|
# `remote_folder` overrides `sftp_config.remote_folder` but NOT `remote_subfolder`
|
115
132
|
def remote_folder(subfolder = remote_subfolder)
|
133
|
+
return super if defined?(super) && !super.nil?
|
134
|
+
|
116
135
|
rm_tf = options.dig(:sftp, :remote_target_folder)
|
117
136
|
return rm_tf if rm_tf
|
118
137
|
|
@@ -121,6 +140,8 @@ module Eco::API::UseCases::Lib
|
|
121
140
|
end
|
122
141
|
|
123
142
|
def remote_subfolder(required: true)
|
143
|
+
return super if defined?(super) && !super.nil?
|
144
|
+
|
124
145
|
remote_subdir = options.dig(:sftp, :remote_subfolder)
|
125
146
|
remote_subdir ||= self.class::REMOTE_FOLDER if self.class.const_defined?(:REMOTE_FOLDER)
|
126
147
|
remote_subdir ||= self.class::REMOTE_SUBFOLDER if self.class.const_defined?(:REMOTE_SUBFOLDER)
|
@@ -132,16 +153,6 @@ module Eco::API::UseCases::Lib
|
|
132
153
|
raise UnspecifiedRemoteFolder, msg
|
133
154
|
end
|
134
155
|
|
135
|
-
def local_folder
|
136
|
-
if (local_dir = options.dig(:sftp, :local_folder))
|
137
|
-
local_dir
|
138
|
-
elsif self.class.const_defined?(:LOCAL_FOLDER)
|
139
|
-
self.class::LOCAL_FOLDER
|
140
|
-
else
|
141
|
-
'.'
|
142
|
-
end
|
143
|
-
end
|
144
|
-
|
145
156
|
# @param subfolder [String] the subfolder.
|
146
157
|
def with_remote_files(subfolder: remote_subfolder, pattern: nil)
|
147
158
|
sftp.files(remote_folder(subfolder), pattern: pattern).each do |remote_file|
|
data/lib/eco/api/usecases/lib.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
# Use case to export a register into a CSV
|
2
2
|
class Eco::API::UseCases::OozeCases::ExportRegisterCase < Eco::API::UseCases::OozeSamples::RegisterExportCase
|
3
|
-
name
|
3
|
+
name 'export-register'
|
4
4
|
type :other
|
5
5
|
batch_size 5
|
6
6
|
|
7
7
|
def main(session, options, usecase)
|
8
|
-
super
|
8
|
+
super do
|
9
9
|
# Save the File
|
10
|
-
CSV.open(filename,
|
10
|
+
CSV.open(filename, 'w') do |csv|
|
11
11
|
csv << exportable_register.header(refresh: true)
|
12
12
|
exportable_register.each(as_values: true) do |values|
|
13
13
|
csv << values
|
@@ -79,7 +79,7 @@ class Eco::API::UseCases::OozeCases::ExportRegisterCase < Eco::API::UseCases::Oo
|
|
79
79
|
end
|
80
80
|
|
81
81
|
def options_delimiter
|
82
|
-
options.dig(:export, :options, :delimiter) ||
|
82
|
+
options.dig(:export, :options, :delimiter) || '|'
|
83
83
|
end
|
84
84
|
|
85
85
|
def include_deindexed?
|
@@ -94,7 +94,7 @@ class Eco::API::UseCases::OozeCases::ExportRegisterCase < Eco::API::UseCases::Oo
|
|
94
94
|
@filename ||= (options[:file] || options.dig(:export, :file, :name)).tap do |filename|
|
95
95
|
next if filename
|
96
96
|
|
97
|
-
log(:error) {
|
97
|
+
log(:error) { 'Destination file not specified' }
|
98
98
|
return false
|
99
99
|
end
|
100
100
|
end
|
@@ -5,16 +5,16 @@ module Eco
|
|
5
5
|
module Helpers
|
6
6
|
# Class to ease the export process
|
7
7
|
class ExportableOoze
|
8
|
-
MERGE_DELIMITER =
|
8
|
+
MERGE_DELIMITER = '#:#'.freeze
|
9
9
|
META_FIELDS = {
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
10
|
+
'id' => 'Internal ID',
|
11
|
+
'uid' => 'Unique ID',
|
12
|
+
'name' => 'Name of Page',
|
13
|
+
'state' => 'State of Page',
|
14
|
+
'time_zone' => 'Time Zone',
|
15
|
+
'created_at' => 'Page Created',
|
16
|
+
'updated_at' => 'Last updated',
|
17
|
+
'tags' => 'Location Tags'
|
18
18
|
}.freeze
|
19
19
|
DEFAULT_OPTIONS = {
|
20
20
|
delimiter: "\n",
|
@@ -31,9 +31,10 @@ module Eco
|
|
31
31
|
def label(field, default: nil)
|
32
32
|
value = nil
|
33
33
|
value ||= field.label.to_s.strip if field.respond_to?(:label)
|
34
|
-
value = nil
|
34
|
+
value = nil unless value && !value.empty?
|
35
35
|
return value if value || !default
|
36
|
-
|
36
|
+
|
37
|
+
default || 'Unnamed field:'
|
37
38
|
end
|
38
39
|
|
39
40
|
def key_ref_label(field, default: nil)
|
@@ -157,6 +158,7 @@ module Eco
|
|
157
158
|
return false if opts[:only_indexed] && !self.class.indexed?(field)
|
158
159
|
return false if opts[:only_labeled] && !self.class.label?(field)
|
159
160
|
return false if opts[:only_with_ref] && !self.class.with_ref?(field)
|
161
|
+
|
160
162
|
true
|
161
163
|
end
|
162
164
|
|
@@ -167,6 +169,7 @@ module Eco
|
|
167
169
|
def to_value(field, delimiter: self.delimiter)
|
168
170
|
return nil unless field.respond_to?(:to_s)
|
169
171
|
return field.to_s unless offers_delimiter?(field.method(:to_s))
|
172
|
+
|
170
173
|
field.to_s(delimiter: delimiter)
|
171
174
|
end
|
172
175
|
|