eco-helpers 3.0.26 → 3.0.28
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 +76 -5
- data/eco-helpers.gemspec +2 -1
- data/lib/eco/api/common/class_helpers.rb +1 -136
- data/lib/eco/api/common/loaders/base.rb +1 -1
- data/lib/eco/api/common/loaders/case_base.rb +1 -1
- data/lib/eco/api/common/loaders/config/cli.rb +1 -1
- data/lib/eco/api/common/loaders/config/session.rb +1 -1
- data/lib/eco/api/common/loaders/config/workflow.rb +1 -1
- data/lib/eco/api/common/loaders/config.rb +2 -5
- 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/target_model.rb +1 -1
- data/lib/eco/api/common/loaders/use_case/type.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/people/supervisor_helpers.rb +3 -1
- data/lib/eco/api/common/session/logger/channels.rb +2 -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 +2 -1
- data/lib/eco/api/common/session/mailer/sendgrid_provider.rb +9 -9
- data/lib/eco/api/common/session/mailer.rb +5 -3
- data/lib/eco/api/common/session/sftp.rb +11 -4
- 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/sets.rb +1 -0
- data/lib/eco/api/session/batch/job/type.rb +1 -0
- data/lib/eco/api/session/batch/job.rb +2 -2
- data/lib/eco/api/session/batch/launcher/valid_methods.rb +3 -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 +2 -2
- 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_case/model.rb +2 -1
- data/lib/eco/api/usecases/base_case/type.rb +2 -1
- data/lib/eco/api/usecases/base_io/validations.rb +6 -4
- 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 +5 -3
- 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} +1 -1
- data/lib/eco/api/usecases/lib/{sftp.rb → files/sftp.rb} +19 -7
- 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 +5 -3
- 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 +7 -5
- 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 +69 -50
- data/lib/eco/data/hashes/diff_result/meta.rb +2 -1
- data/lib/eco/data/locations/node_base/treeify.rb +13 -11
- data/lib/eco/data/locations/node_diff/accessors.rb +2 -1
- data/lib/eco/data/mapper.rb +4 -4
- data/lib/eco/language/auxiliar_logger.rb +4 -4
- data/lib/eco/language/delegation/chainable_delegator.rb +18 -0
- data/lib/eco/language/delegation/delegating_missing.rb +104 -0
- data/lib/eco/language/delegation/delegating_missing_const.rb +53 -0
- data/lib/eco/language/delegation/delegating_missing_on_class.rb +53 -0
- data/lib/eco/language/delegation/for_delegator/const_delegator.rb +66 -0
- data/lib/eco/language/delegation/for_delegator/const_lookup_hooks.rb +99 -0
- data/lib/eco/language/delegation/for_delegator/delegated_class.rb +71 -0
- data/lib/eco/language/delegation/for_delegator.rb +11 -0
- data/lib/eco/language/delegation.rb +10 -0
- data/lib/eco/language/klass/builder.rb +29 -0
- data/lib/eco/language/klass/helpers_built.rb +9 -0
- data/lib/eco/language/klass/hierarchy.rb +34 -0
- data/lib/eco/language/klass/inheritable_class_vars.rb +45 -0
- data/lib/eco/language/klass/naming.rb +21 -0
- data/lib/eco/language/klass/resolver.rb +30 -0
- data/lib/eco/language/klass/when_inherited.rb +11 -13
- data/lib/eco/language/klass.rb +6 -0
- data/lib/eco/language/methods.rb +0 -1
- data/lib/eco/language/models/class_helpers.rb +25 -23
- data/lib/eco/language/models/collection.rb +12 -2
- data/lib/eco/language/strings/underscore.rb +17 -0
- data/lib/eco/language/strings.rb +8 -0
- data/lib/eco/language.rb +2 -0
- data/lib/eco/version.rb +1 -1
- metadata +39 -7
- data/lib/eco/language/methods/delegate_missing.rb +0 -29
@@ -12,6 +12,7 @@ class Eco::API::UseCases::BaseIO
|
|
12
12
|
msg = "#{msg} of type '#{type}'" if type
|
13
13
|
msg = "#{msg} (#{klass})" if klass
|
14
14
|
msg = "#{msg} requires an object '#{required}'. Given: #{given}."
|
15
|
+
|
15
16
|
super(msg)
|
16
17
|
end
|
17
18
|
|
@@ -28,7 +29,8 @@ class Eco::API::UseCases::BaseIO
|
|
28
29
|
class << self
|
29
30
|
def included(base)
|
30
31
|
super
|
31
|
-
|
32
|
+
|
33
|
+
base.extend ClassMethods
|
32
34
|
end
|
33
35
|
end
|
34
36
|
|
@@ -71,9 +73,9 @@ class Eco::API::UseCases::BaseIO
|
|
71
73
|
elsif missing_data?
|
72
74
|
raise MissingParameter.new(
|
73
75
|
'UseCase',
|
74
|
-
type:
|
75
|
-
required:
|
76
|
-
given:
|
76
|
+
type: type,
|
77
|
+
required: model,
|
78
|
+
given: data.class,
|
77
79
|
usecase: self
|
78
80
|
)
|
79
81
|
elsif !options.is_a?(Hash)
|
@@ -4,7 +4,9 @@ class Eco::API::UseCases::Cli
|
|
4
4
|
attr_accessor :name, :desc, :callback
|
5
5
|
|
6
6
|
def initialize(name, desc, &block)
|
7
|
-
@name
|
7
|
+
@name = name
|
8
|
+
@desc = desc
|
9
|
+
@callback = block
|
8
10
|
end
|
9
11
|
|
10
12
|
def dup(name: self.name, desc: self.desc, &block)
|
@@ -12,7 +14,8 @@ class Eco::API::UseCases::Cli
|
|
12
14
|
end
|
13
15
|
|
14
16
|
def link_case(cli_config_case)
|
15
|
-
|
17
|
+
msg = "cli_config_case must have an 'add_option' method. Given: #{cli_config_case.class}"
|
18
|
+
raise ArgumentError, msg unless cli_config_case.respond_to?(:add_option)
|
16
19
|
|
17
20
|
cli_config_case.add_option(name, desc, &callback)
|
18
21
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
class Eco::API::UseCases::Default::People::Amend::ClearAbilitiesTransCase < Eco::API::Common::Loaders::UseCase
|
2
|
-
name
|
2
|
+
name 'clear-abilities'
|
3
3
|
type :transform
|
4
4
|
|
5
5
|
def main(*_args)
|
@@ -9,7 +9,7 @@ class Eco::API::UseCases::Default::People::Amend::ClearAbilitiesTransCase < Eco:
|
|
9
9
|
private
|
10
10
|
|
11
11
|
def clear_abilities(users)
|
12
|
-
update = session.new_job(
|
12
|
+
update = session.new_job('main', 'clear-abilities', :update, usecase, :account)
|
13
13
|
users.each do |person|
|
14
14
|
person.account.permissions_custom = nil_abilities.dup
|
15
15
|
update.add(person)
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# @example
|
2
2
|
# -restore-db-from backup.json -skip-api-policies -skip-batch-policy -include-excluded -simulate
|
3
3
|
class Eco::API::UseCases::Default::People::Amend::RestoreDBCase < Eco::API::Common::Loaders::UseCase
|
4
|
-
name
|
4
|
+
name 'restore-db'
|
5
5
|
type :sync
|
6
6
|
|
7
7
|
require_relative 'cli/restore_db_cli'
|
@@ -9,9 +9,9 @@ class Eco::API::UseCases::Default::People::Amend::RestoreDBCase < Eco::API::Comm
|
|
9
9
|
def main(entries, people, session, options, usecase) # rubocop:disable Metrics/AbcSize
|
10
10
|
require_people_as_entries!(entries)
|
11
11
|
|
12
|
-
restart = session.new_job(
|
13
|
-
update = session.new_job(
|
14
|
-
delete = session.new_job(
|
12
|
+
restart = session.new_job('main', 'restart', :create, usecase) if options.dig(:include, :create)
|
13
|
+
update = session.new_job('main', 'update', :update, usecase)
|
14
|
+
delete = session.new_job('main', 'delete', :update, usecase)
|
15
15
|
|
16
16
|
if options.dig(:include, :delete)
|
17
17
|
micro.with_each_leaver(entries, people, options) do |person|
|
@@ -43,13 +43,20 @@ class Eco::API::UseCases::Default::People::Amend::RestoreDBCase < Eco::API::Comm
|
|
43
43
|
|
44
44
|
private
|
45
45
|
|
46
|
-
def core_copy(entry, person)
|
46
|
+
def core_copy(entry, person) # rubocop:disable Metrics/AbcSize
|
47
|
+
person.archived = entry.archived unless options.dig(:exclude, :archived)
|
47
48
|
person.external_id = entry.external_id unless options.dig(:exclude, :external_id)
|
48
49
|
person.name = entry.name unless options.dig(:exclude, :name)
|
49
50
|
person.email = entry.email unless options.dig(:exclude, :email)
|
50
51
|
person.supervisor_id = entry.supervisor_id unless options.dig(:exclude, :supervisor)
|
51
52
|
person.filter_tags = entry.filter_tags unless options.dig(:exclude, :filter_tags)
|
52
|
-
|
53
|
+
|
54
|
+
unless options.dig(:exclude, :contractor_organization_id)
|
55
|
+
person.contractor_organization_id =
|
56
|
+
entry.contractor_organization_id
|
57
|
+
end
|
58
|
+
|
59
|
+
person.freemium = entry.freemium
|
53
60
|
end
|
54
61
|
|
55
62
|
def account_copy(src, dst) # rubocop:disable Metrics/AbcSize
|
@@ -64,7 +71,7 @@ class Eco::API::UseCases::Default::People::Amend::RestoreDBCase < Eco::API::Comm
|
|
64
71
|
end
|
65
72
|
|
66
73
|
if src.preferences # rubocop:disable Style/IfUnlessModifier
|
67
|
-
dst.doc[
|
74
|
+
dst.doc['preferences'] = JSON.parse((src.doc['preferences'] || {}).to_json)
|
68
75
|
end
|
69
76
|
|
70
77
|
unless options[:source_enviro]
|
@@ -92,8 +99,8 @@ class Eco::API::UseCases::Default::People::Amend::RestoreDBCase < Eco::API::Comm
|
|
92
99
|
log(:error) {
|
93
100
|
msg = []
|
94
101
|
msg << "There were #{re_starters.length} entries of the backup "
|
95
|
-
msg <<
|
96
|
-
msg <<
|
102
|
+
msg << 'that do not exist in the (filtered?) people manager.'
|
103
|
+
msg << 'Some examples:'
|
97
104
|
msg << " * #{examples.join("\n * ")}"
|
98
105
|
msg.join("\n")
|
99
106
|
}
|
@@ -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
|
@@ -4,8 +4,9 @@ class Eco::API::UseCases::GraphQL::Helpers::Location::Command::Diffs
|
|
4
4
|
class << self
|
5
5
|
def included(base)
|
6
6
|
super
|
7
|
-
|
8
|
-
base.
|
7
|
+
|
8
|
+
base.extend ClassMethods
|
9
|
+
base.send :include, DiffSortable
|
9
10
|
end
|
10
11
|
end
|
11
12
|
|
@@ -37,7 +38,8 @@ class Eco::API::UseCases::GraphQL::Helpers::Location::Command::Diffs
|
|
37
38
|
end
|
38
39
|
|
39
40
|
def stage_diffs(stage)
|
40
|
-
|
41
|
+
msg = "There is NO support for stage '#{stage}'. Please review"
|
42
|
+
raise ArgumentError, msg unless respond_to?(stage)
|
41
43
|
|
42
44
|
sort_diffs(stage) do
|
43
45
|
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 = {
|