eco-helpers 2.0.13 → 2.0.18
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 +87 -2
- data/eco-helpers.gemspec +6 -4
- data/lib/eco-helpers.rb +2 -0
- data/lib/eco/api/common/base_loader.rb +14 -0
- data/lib/eco/api/common/people/default_parsers/date_parser.rb +11 -1
- data/lib/eco/api/common/people/default_parsers/login_providers_parser.rb +1 -1
- data/lib/eco/api/common/people/default_parsers/policy_groups_parser.rb +11 -11
- data/lib/eco/api/common/people/person_entry.rb +9 -2
- data/lib/eco/api/common/people/supervisor_helpers.rb +27 -0
- data/lib/eco/api/common/session/file_manager.rb +2 -2
- data/lib/eco/api/common/session/mailer.rb +0 -1
- data/lib/eco/api/common/session/s3_uploader.rb +0 -1
- data/lib/eco/api/common/session/sftp.rb +0 -1
- data/lib/eco/api/common/version_patches/exception.rb +8 -4
- data/lib/eco/api/error.rb +5 -3
- data/lib/eco/api/microcases.rb +3 -1
- data/lib/eco/api/microcases/append_usergroups.rb +0 -1
- data/lib/eco/api/microcases/people_cache.rb +2 -2
- data/lib/eco/api/microcases/people_load.rb +2 -2
- data/lib/eco/api/microcases/people_refresh.rb +2 -2
- data/lib/eco/api/microcases/people_search.rb +6 -6
- data/lib/eco/api/microcases/preserve_default_tag.rb +23 -0
- data/lib/eco/api/microcases/preserve_filter_tags.rb +28 -0
- data/lib/eco/api/microcases/preserve_policy_groups.rb +30 -0
- data/lib/eco/api/microcases/set_account.rb +0 -1
- data/lib/eco/api/organization.rb +1 -0
- data/lib/eco/api/organization/people.rb +7 -0
- data/lib/eco/api/organization/people_analytics.rb +60 -0
- data/lib/eco/api/organization/presets_factory.rb +116 -93
- data/lib/eco/api/organization/presets_integrity.json +58 -0
- data/lib/eco/api/organization/presets_values.json +5 -4
- data/lib/eco/api/policies/default_policies/99_user_access_policy.rb +0 -30
- data/lib/eco/api/session.rb +1 -20
- data/lib/eco/api/session/batch.rb +23 -7
- data/lib/eco/api/session/batch/job.rb +3 -0
- data/lib/eco/api/session/config.rb +16 -15
- data/lib/eco/api/session/config/api.rb +4 -0
- data/lib/eco/api/session/config/apis.rb +80 -0
- data/lib/eco/api/session/config/files.rb +7 -0
- data/lib/eco/api/session/config/people.rb +3 -19
- data/lib/eco/api/usecases/default_cases.rb +4 -1
- data/lib/eco/api/usecases/default_cases/abstract_policygroup_abilities_case.rb +161 -0
- data/lib/eco/api/usecases/default_cases/analyse_people_case.rb +76 -0
- data/lib/eco/api/usecases/default_cases/codes_to_tags_case.rb +2 -3
- data/lib/eco/api/usecases/default_cases/reset_landing_page_case.rb +11 -1
- data/lib/eco/api/usecases/default_cases/restore_db_case.rb +1 -2
- data/lib/eco/api/usecases/default_cases/supers_cyclic_identify_case.rb +72 -0
- data/lib/eco/api/usecases/default_cases/supers_hierarchy_case.rb +59 -0
- data/lib/eco/api/usecases/default_cases/to_csv_case.rb +104 -26
- data/lib/eco/api/usecases/default_cases/to_csv_detailed_case.rb +62 -36
- data/lib/eco/cli.rb +0 -10
- data/lib/eco/cli/config/default/options.rb +19 -17
- data/lib/eco/cli/config/default/people_filters.rb +3 -3
- data/lib/eco/cli/config/default/usecases.rb +77 -25
- data/lib/eco/cli/config/default/workflow.rb +12 -3
- data/lib/eco/cli/config/help.rb +1 -0
- data/lib/eco/cli/config/options_set.rb +106 -13
- data/lib/eco/cli/config/use_cases.rb +33 -33
- data/lib/eco/cli/scripting/args_helpers.rb +30 -3
- data/lib/eco/data.rb +1 -0
- data/lib/eco/data/crypto/encryption.rb +3 -3
- data/lib/eco/data/files/directory.rb +28 -20
- data/lib/eco/data/files/helpers.rb +6 -4
- data/lib/eco/data/fuzzy_match.rb +119 -0
- data/lib/eco/data/fuzzy_match/array_helpers.rb +75 -0
- data/lib/eco/data/fuzzy_match/chars_position_score.rb +37 -0
- data/lib/eco/data/fuzzy_match/ngrams_score.rb +73 -0
- data/lib/eco/data/fuzzy_match/pairing.rb +102 -0
- data/lib/eco/data/fuzzy_match/result.rb +67 -0
- data/lib/eco/data/fuzzy_match/results.rb +53 -0
- data/lib/eco/data/fuzzy_match/score.rb +44 -0
- data/lib/eco/data/fuzzy_match/stop_words.rb +35 -0
- data/lib/eco/data/fuzzy_match/string_helpers.rb +69 -0
- data/lib/eco/version.rb +1 -1
- metadata +86 -10
- data/lib/eco/api/microcases/refresh_abilities.rb +0 -19
- data/lib/eco/api/organization/presets_reference.json +0 -59
- data/lib/eco/api/usecases/default_cases/refresh_abilities_case.rb +0 -30
@@ -1,53 +1,79 @@
|
|
1
|
-
class Eco::API::UseCases::DefaultCases::ToCsvDetailedCase < Eco::API::
|
1
|
+
class Eco::API::UseCases::DefaultCases::ToCsvDetailedCase < Eco::API::UseCases::DefaultCases::ToCsvCase
|
2
2
|
name "to-csv-detailed"
|
3
3
|
type :export
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
5
|
+
private
|
6
|
+
|
7
|
+
def to_row(person)
|
8
|
+
entry = to_entry_type(person)
|
9
|
+
data = entry.values_at(*keys(entry))
|
10
|
+
data << person.subordinates
|
11
|
+
data << person_supervisor(person)
|
12
|
+
data += user_abilities(person)
|
13
|
+
data += user_permissions_custom(person) if options.dig(:export, :options, :permissions_custom)
|
14
|
+
account = person.account
|
15
|
+
data << account&.landing_page_id
|
16
|
+
data += user_preferences(person)
|
17
|
+
data
|
18
|
+
end
|
10
19
|
|
11
|
-
|
12
|
-
|
13
|
-
return
|
20
|
+
def person_supervisor(person)
|
21
|
+
session.micro.with_supervisor(person.supervisor_id, people) do |supervisor|
|
22
|
+
return supervisor ? supervisor.name : ""
|
14
23
|
end
|
24
|
+
end
|
15
25
|
|
16
|
-
|
17
|
-
|
26
|
+
def user_abilities(person)
|
27
|
+
account_abilities = (person.account && person.account.permissions_merged) || {}
|
28
|
+
abilities.map {|key| account_abilities[key] || "no access"}
|
29
|
+
end
|
18
30
|
|
19
|
-
|
20
|
-
|
21
|
-
|
31
|
+
def user_permissions_custom(person)
|
32
|
+
account_abilities = (person.account && person.account.permissions_custom) || {}
|
33
|
+
abilities.map {|key| account_abilities[key] || "no access"}
|
34
|
+
end
|
22
35
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
header += ["Supervisor Name"]
|
28
|
-
header += abilities
|
29
|
-
header += ["Landing Page"]
|
36
|
+
def user_preferences(person)
|
37
|
+
user_preferences = (person.account && person.account.preferences&.doc) || {}
|
38
|
+
preferences.map {|key| user_preferences[key] || false}
|
39
|
+
end
|
30
40
|
|
31
|
-
|
32
|
-
|
33
|
-
|
41
|
+
def spot_header
|
42
|
+
super do |header|
|
43
|
+
header << "Subordinates"
|
44
|
+
header << "Supervisor Name"
|
45
|
+
header += abilities_header
|
46
|
+
header += abilities_header("custom") if options.dig(:export, :options, :permissions_custom)
|
47
|
+
header << "Landing Page"
|
48
|
+
header += preferences
|
49
|
+
header
|
50
|
+
end
|
51
|
+
end
|
34
52
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
end
|
53
|
+
def keys(entry)
|
54
|
+
super(entry) + ["freemium"]
|
55
|
+
end
|
39
56
|
|
40
|
-
|
41
|
-
|
57
|
+
def login_providers
|
58
|
+
session.login_providers
|
59
|
+
end
|
42
60
|
|
43
|
-
|
44
|
-
|
45
|
-
|
61
|
+
def abilities
|
62
|
+
@abilities ||= session.presets_factory.keys
|
63
|
+
end
|
46
64
|
|
47
|
-
|
48
|
-
|
65
|
+
def abilities_header(prefix = nil)
|
66
|
+
abilities.map do |key|
|
67
|
+
prefix ? "#{prefix}_#{key}" : key
|
49
68
|
end
|
50
|
-
|
69
|
+
end
|
70
|
+
|
71
|
+
def preferences
|
72
|
+
@preferences ||= [
|
73
|
+
"show_sidebar", "show_shortcuts", "show_coming_soon", "show_recently_visited_forms",
|
74
|
+
"show_tasks", "show_task_bubbles",
|
75
|
+
"kiosk_enabled"
|
76
|
+
]
|
51
77
|
end
|
52
78
|
|
53
79
|
end
|
data/lib/eco/cli.rb
CHANGED
@@ -23,16 +23,6 @@ module Eco
|
|
23
23
|
def run(session:)
|
24
24
|
io = Eco::API::UseCases::BaseIO.new(session: session, options: options)
|
25
25
|
session.workflow(io: io).run(io: io)
|
26
|
-
#session.workflow(io: io) do |wf, io|
|
27
|
-
# io = wf.run(:options, io: io)
|
28
|
-
# io = wf.run(:load, io: io)
|
29
|
-
# io = wf.run(:usecases, io: io)
|
30
|
-
# io = wf.run(:launch_jobs, io: io)
|
31
|
-
# io = wf.run(:post_launch, io: io)
|
32
|
-
# io = wf.run(:report, io: io)
|
33
|
-
# io = wf.run(:end, io: io)
|
34
|
-
# io = wf.run(:close, io: io)
|
35
|
-
#end
|
36
26
|
end
|
37
27
|
|
38
28
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
ASSETS.cli.config do |cnf|
|
2
2
|
cnf.options_set do |options_set, options|
|
3
|
-
options_set.add("--help", "
|
3
|
+
options_set.add("--help", "Offers a HELP") do |options, sesssion|
|
4
4
|
conf = ASSETS.cli.config
|
5
5
|
puts conf.people_filters.help if hpf = SCR.get_arg("-filters")
|
6
6
|
puts conf.input_filters.help if hif = SCR.get_arg("-input-filters")
|
@@ -11,12 +11,14 @@ ASSETS.cli.config do |cnf|
|
|
11
11
|
" -filters to display available filters on people",
|
12
12
|
" -input-filters to display available filters on input data",
|
13
13
|
" -options to dislpay available options",
|
14
|
-
" -usecases to display available usecases"
|
14
|
+
" -usecases to display available usecases",
|
15
|
+
"",
|
16
|
+
"You may specify the usecase to know its specific options by: -usecase_name --help -options"
|
15
17
|
].join("\n") unless hpf || hif || ho || huc
|
16
18
|
exit
|
17
19
|
end
|
18
20
|
|
19
|
-
desc = "
|
21
|
+
desc = "Fix the current session to work with this schema"
|
20
22
|
options_set.add("-schema-id", desc) do |options, session|
|
21
23
|
sch_name = SCR.get_arg("-schema-id", with_param: true)
|
22
24
|
sch_id = session.schemas.to_id(sch_name)
|
@@ -33,67 +35,67 @@ ASSETS.cli.config do |cnf|
|
|
33
35
|
session.schema = sch_id
|
34
36
|
end
|
35
37
|
|
36
|
-
desc = "
|
38
|
+
desc = "Deprecated: used to be used to specify the input file when using -get-partial"
|
37
39
|
options_set.add("-entries-from", desc) do |options, session|
|
38
40
|
options.deep_merge!(input: {entries_from: true})
|
39
41
|
end
|
40
42
|
|
41
|
-
desc = "
|
43
|
+
desc = "Locally cache all the people manager by retrieving from the server"
|
42
44
|
options_set.add("-get-people", desc) do |options, session|
|
43
45
|
options.deep_merge!(people: {
|
44
46
|
get: {from: :remote, type: :full}
|
45
47
|
})
|
46
48
|
end
|
47
49
|
|
48
|
-
options_set.add(["-dry-run", "-simulate"], "
|
50
|
+
options_set.add(["-dry-run", "-simulate"], "Runs in dry-run (no requests sent to server)") do |options, session|
|
49
51
|
options[:dry_run] = true
|
50
52
|
options[:simulate] = true
|
51
53
|
session.config.dry_run!
|
52
54
|
end
|
53
55
|
|
54
|
-
desc = "
|
56
|
+
desc = "Ignores threshold limitations on requests for this session (skip batch belt)"
|
55
57
|
options_set.add("-skip-batch-policy", desc) do |options|
|
56
58
|
options.deep_merge!(skip: {batch_policy: true})
|
57
59
|
end
|
58
60
|
|
59
|
-
desc = "
|
61
|
+
desc = "Will not run the api policies defined for the enviro"
|
60
62
|
options_set.add("-skip-api-policies", desc) do |options|
|
61
63
|
options.deep_merge!(skip: {api_policies: true})
|
62
64
|
end
|
63
65
|
|
64
|
-
options_set.add("-feed-only-stats", "
|
66
|
+
options_set.add("-feed-only-stats", "Shows only stats when giving feedback") do |options|
|
65
67
|
options.deep_merge!(feedback: {only_stats: true})
|
66
68
|
end
|
67
69
|
|
68
|
-
desc = "
|
70
|
+
desc = "Deprecated: used to be used to avoid reloading people after launch"
|
69
71
|
options[:end_get] = true
|
70
72
|
options_set.add("-no-get", desc) do |options|
|
71
73
|
options[:end_get] = false
|
72
74
|
end
|
73
75
|
|
74
|
-
desc = "
|
76
|
+
desc = "Force search mode to 'strict' when pairing input entries with existing people."
|
75
77
|
desc += " Besides id and external_id it will not try to find by email unless external_id is not specified"
|
76
78
|
options_set.add("-search-strict", desc) do |options|
|
77
79
|
options.deep_merge!(search: {strict: true})
|
78
80
|
end
|
79
81
|
|
80
|
-
desc = "
|
82
|
+
desc = "Search mode that will try to find people using email when id and external_id have failed"
|
81
83
|
desc += " This option could identify existing people by their email addresses"
|
82
84
|
desc += " (it should not be used in orgs where multiple people usually have the same email address)"
|
83
85
|
options_set.add("-search-soft", desc) do |options|
|
84
86
|
options.deep_merge!(search: {soft: true, strict: false})
|
85
87
|
end
|
86
88
|
|
87
|
-
desc = "
|
89
|
+
desc = "Silence notifications on account creation or invites"
|
88
90
|
options_set.add(["-no-invites", "-exclude-invites"], desc) do |options|
|
89
91
|
options.merge!(send_invites: false)
|
90
92
|
end
|
91
|
-
desc = "
|
93
|
+
desc = "People with account will be reinvited if they haven't accepted the invitation"
|
92
94
|
options_set.add("-send-invites", desc) do |options|
|
93
95
|
options.merge!(send_invites: true)
|
94
96
|
end
|
95
97
|
|
96
|
-
options_set.add("-exclude-core", "
|
98
|
+
options_set.add("-exclude-core", "Core input data is not used on the update") do |options|
|
97
99
|
options.deep_merge!(exclude: {core: true})
|
98
100
|
end
|
99
101
|
options_set.add("-exclude-filter-tags", "filter_tags is not set with the input data") do |options|
|
@@ -112,11 +114,11 @@ ASSETS.cli.config do |cnf|
|
|
112
114
|
options.deep_merge!(exclude: {name: true})
|
113
115
|
end
|
114
116
|
|
115
|
-
options_set.add("-exclude-details", "
|
117
|
+
options_set.add("-exclude-details", "Details are not set with the input data") do |options|
|
116
118
|
options.deep_merge!(exclude: {details: true})
|
117
119
|
end
|
118
120
|
|
119
|
-
options_set.add("-exclude-account", "
|
121
|
+
options_set.add("-exclude-account", "Account is not set with the input data") do |options|
|
120
122
|
options.deep_merge!(exclude: {account: true})
|
121
123
|
end
|
122
124
|
options_set.add("-exclude-policy-groups", "policy_group_ids is not set with the input data") do |options|
|
@@ -52,7 +52,7 @@ ASSETS.cli.config do |cnf|
|
|
52
52
|
|
53
53
|
desc = "only those that have ALL the specified tags separated by '|'"
|
54
54
|
filters.add("-filter-tags-all", desc) do |people, session, options|
|
55
|
-
tags = SCR.get_arg("-filter-tags-all", with_param: true).upcase.split("|")
|
55
|
+
tags = SCR.get_arg("-filter-tags-all", with_param: true).upcase.split("|").compact
|
56
56
|
options.deep_merge!(input: {filter: {filter_tags: {any: tags}}})
|
57
57
|
people.filter_tags_all(tags).tap do |filtered|
|
58
58
|
msg = "Filtered #{filtered.count} people (out of #{people.count}) with 'all' filter_tags #{tags}"
|
@@ -62,7 +62,7 @@ ASSETS.cli.config do |cnf|
|
|
62
62
|
|
63
63
|
desc = "only those that have ANY the specified tags separated by '|'"
|
64
64
|
filters.add("-filter-tags-any", desc) do |people, session, options|
|
65
|
-
tags = SCR.get_arg("-filter-tags-any", with_param: true).upcase.split("|")
|
65
|
+
tags = SCR.get_arg("-filter-tags-any", with_param: true).upcase.split("|").compact
|
66
66
|
options.deep_merge!(input: {filter: {filter_tags_any: tags}})
|
67
67
|
people.filter_tags_any(tags).tap do |filtered|
|
68
68
|
msg = "Filtered #{filtered.count} people (out of #{people.count}) with 'any' filter_tags #{tags}"
|
@@ -72,7 +72,7 @@ ASSETS.cli.config do |cnf|
|
|
72
72
|
|
73
73
|
desc = "only those that have ANY tag in the specified subtrees separated by '|'"
|
74
74
|
filters.add("-filter-tags-tree", desc) do |people, session, options|
|
75
|
-
top_tags = SCR.get_arg("-filter-tags-tree", with_param: true).upcase.split("|")
|
75
|
+
top_tags = SCR.get_arg("-filter-tags-tree", with_param: true).upcase.split("|").compact
|
76
76
|
tags = top_tags.each_with_object([]) do |top, tags|
|
77
77
|
tags.concat(session.tagtree.node(top).tags)
|
78
78
|
end.uniq
|
@@ -1,27 +1,72 @@
|
|
1
1
|
ASSETS.cli.config do |cnf|
|
2
2
|
cnf.usecases do |cases|
|
3
3
|
|
4
|
+
desc = "Draws the Supervisors hiearchy in a file"
|
5
|
+
cases.add("-supers-hierarchy", :export, desc, case_name: "supers-hierarchy") do |people, session, options|
|
6
|
+
options.deep_merge!(output: {file: "supers_hierarchy.txt"}) unless options.dig(:output, :file)
|
7
|
+
end.add_option("-to", "Specify the output file") do |options|
|
8
|
+
file = SCR.get_file("-to", required: true, should_exist: false)
|
9
|
+
options.deep_merge!(output: {file: file})
|
10
|
+
end
|
11
|
+
|
12
|
+
desc = "Draws the Cyclic Supervisors when identified"
|
13
|
+
cases.add("-identify-cyclic-supers", :export, desc, case_name: "identify-cyclic-supers") do |people, session, options|
|
14
|
+
options.deep_merge!(output: {file: "cyclic_supers.txt"}) unless options.dig(:output, :file)
|
15
|
+
end.add_option("-to", "Specify the output file") do |options|
|
16
|
+
file = SCR.get_file("-to", required: true, should_exist: false)
|
17
|
+
options.deep_merge!(output: {file: file})
|
18
|
+
end
|
19
|
+
|
20
|
+
desc = "Abstracts the Abilities that each Usergroup should probably have"
|
21
|
+
cases.add("-abstract-policygroup-abilities", :export, desc, case_name: "abstract-policygroup-abilities") do |people, session, options|
|
22
|
+
options.deep_merge!(output: {file: "suggested_usergroup_abilities.txt"}) unless options.dig(:output, :file)
|
23
|
+
end.add_option("-to", "Specify the output file") do |options|
|
24
|
+
file = SCR.get_file("-to", required: true, should_exist: false)
|
25
|
+
options.deep_merge!(output: {file: file})
|
26
|
+
end
|
27
|
+
|
28
|
+
desc = "Provides a set of tools to analyse a set of people (i.e. detect duplicates)"
|
29
|
+
cases.add("-analyse-people", :export, desc, case_name: "-analyse-people") do |people, session, options|
|
30
|
+
options.deep_merge!(output: {file: "people_analysis.txt"}) unless options.dig(:output, :file)
|
31
|
+
end.add_option("-to", "Specify the output file") do |options|
|
32
|
+
file = SCR.get_file("-to", required: true, should_exist: false)
|
33
|
+
options.deep_merge!(output: {file: file})
|
34
|
+
end
|
35
|
+
|
4
36
|
desc = "It exports to a CSV the (filtered) people"
|
5
37
|
cases.add("-people-to-csv", :export, desc) do |people, session, options|
|
6
38
|
file = SCR.get_file("-people-to-csv", required: true, should_exist: false)
|
7
39
|
options.deep_merge!(export: {file: {name: file, format: :csv}})
|
8
|
-
options.deep_merge!(export: {options: {nice_header: true}}) if SCR.get_arg("-nice-header")
|
9
40
|
|
10
|
-
case_name =
|
41
|
+
case_name = options.dig(:export, :options, :detailed) ? "to-csv-detailed" : "to-csv"
|
11
42
|
session.usecases.case(case_name)
|
43
|
+
end.add_option("-nice-header", "Outputs more descriptive standard headers") do |options|
|
44
|
+
options.deep_merge!(export: {options: {nice_header: true}})
|
45
|
+
end.add_option("-internal-names", "It is the most raw export. Useful to see all the data when name mappings override/overlap") do |options|
|
46
|
+
options.deep_merge!(export: {options: {internal_names: true}})
|
47
|
+
end.add_option("-detailed", "Includes much more information to the file (i.e. permissions_merged abilities, preferences)") do |options|
|
48
|
+
options.deep_merge!(export: {options: {detailed: true}})
|
49
|
+
end.add_option("-permissions-custom", "Used with -detailed. Adds the permissions_custom abilities") do |options|
|
50
|
+
options.deep_merge!(export: {options: {permissions_custom: true}})
|
12
51
|
end
|
13
52
|
|
14
53
|
desc = "Adds a column 'ecoPortalTag' to the input CSV with the tags that the location codes map to"
|
15
|
-
cases.add("-codes-to-tags-from", :other, desc, case_name: "codes-to-tags-from")
|
54
|
+
cases.add("-codes-to-tags-from", :other, desc, case_name: "codes-to-tags-from")
|
55
|
+
.add_option("-codes-to-tags-from", "Specify the input 'csv' file") do |options|
|
16
56
|
file = SCR.get_file("-codes-to-tags-from", required: true, should_exist: true)
|
17
57
|
options.deep_merge!(other: {file: {name: file, format: :csv}})
|
18
|
-
|
58
|
+
end.add_option("-column", "Specify the input column header with the codes") do |options|
|
19
59
|
col_codes = SCR.get_arg("-column", with_param: true)
|
20
60
|
options.deep_merge!(other: {file: {codes_column: col_codes}})
|
21
61
|
end
|
22
62
|
|
23
|
-
desc = "Removes the landing page"
|
63
|
+
desc = "Removes the landing page or sets it to -page-id"
|
24
64
|
cases.add("-reset-landing-page", :transform, desc, case_name: "reset-landing-page")
|
65
|
+
.add_option("-page-id", "Target landing page to set to the users") do |options|
|
66
|
+
SCR.get_arg("-page-id", with_param: true).tap do |new_id|
|
67
|
+
options.deep_merge!({page_id: new_id})
|
68
|
+
end
|
69
|
+
end
|
25
70
|
|
26
71
|
desc = "Sets as external_id the email of the person"
|
27
72
|
cases.add("-email-as-id", :transform, desc, case_name: "email-as-id")
|
@@ -36,23 +81,29 @@ ASSETS.cli.config do |cnf|
|
|
36
81
|
|
37
82
|
desc = "Sets the supervisor_id"
|
38
83
|
cases.add("-set-supervisor-from", :sync, desc, case_name: "set-supervisor")
|
84
|
+
|
39
85
|
desc = "Sets to -new-super the supervisor_id of the -old-super's subordinates"
|
40
86
|
cases.add("-switch-supervisor", :transform, desc, case_name: "switch-supervisor") do |people, session, options|
|
41
|
-
unless
|
87
|
+
unless options[:super]&.key?(:old)
|
42
88
|
msg = "You must specify an -old-super to target whose supervisor is changing"
|
43
89
|
session.logger.error(msg)
|
44
90
|
exit(1)
|
45
91
|
end
|
46
|
-
|
47
|
-
options.deep_merge!(super: {old: old_id})
|
48
|
-
|
49
|
-
unless new_id = SCR.get_arg("-new-super", with_param: true)
|
92
|
+
unless options[:super]&.key?(:new)
|
50
93
|
msg = "You must specify the -new-super id. To reset to nil the supervisor, please, specify nil."
|
51
94
|
session.logger.error(msg)
|
52
95
|
exit(1)
|
53
96
|
end
|
54
|
-
|
55
|
-
|
97
|
+
end.add_option("-old-super", "The supervisor id to be replaced on the subordinates") do |options|
|
98
|
+
if old_id = SCR.get_arg("-old-super", with_param: true)
|
99
|
+
old_id = old_id == "nil"? nil : old_id
|
100
|
+
options.deep_merge!(super: {old: old_id})
|
101
|
+
end
|
102
|
+
end.add_option("-new-super", "The new supervisor id") do |options|
|
103
|
+
if new_id = SCR.get_arg("-new-super", with_param: true)
|
104
|
+
new_id = new_id == "nil"? nil : new_id
|
105
|
+
options.deep_merge!(super: {new: new_id})
|
106
|
+
end
|
56
107
|
end
|
57
108
|
|
58
109
|
desc = "Usage '-org-data-convert backup.json -restore-db-from'."
|
@@ -65,15 +116,15 @@ ASSETS.cli.config do |cnf|
|
|
65
116
|
session.logger.info("Source DB: loaded #{input.length} entries.")
|
66
117
|
end
|
67
118
|
|
68
|
-
|
69
|
-
options.merge!(source_enviro: source_enviro)
|
70
|
-
else
|
119
|
+
unless options[:source_enviro]
|
71
120
|
session.logger.error("You need to specify a -source-enviro for the conversion to work out")
|
72
121
|
exit(1)
|
73
122
|
end
|
74
123
|
|
75
|
-
|
76
|
-
|
124
|
+
end.add_option("-source-enviro", "The defined -source-enviro API configuration that the backup file was generated from") do |options|
|
125
|
+
options.merge!(source_enviro: SCR.get_arg("-source-enviro", with_param: true))
|
126
|
+
end.add_option("-ignore-missing-policy-groups", "Prevents the script to crash when backup file has missing usergroups in the org") do |options|
|
127
|
+
options.deep_merge!(ignore: {missing: {policy_groups: true}})
|
77
128
|
end
|
78
129
|
|
79
130
|
desc = "Restores the people manager by using a backup.json file"
|
@@ -83,13 +134,15 @@ ASSETS.cli.config do |cnf|
|
|
83
134
|
input = Eco::API::Organization::People.new(JSON.parse(File.read(file)))
|
84
135
|
session.logger.info("Source DB: loaded #{input.length} entries.")
|
85
136
|
end
|
86
|
-
|
87
|
-
options.deep_merge!(include: {delete: true})
|
88
|
-
|
137
|
+
end.add_option("-include-delete", "If it should DELETE people that do not exist in the backup file") do |options|
|
138
|
+
options.deep_merge!(include: {delete: true})
|
139
|
+
end.add_option("-include-create", "If it should CREATE people that do not exist in the people manager") do |options|
|
140
|
+
options.deep_merge!(include: {create: true})
|
89
141
|
end
|
90
142
|
|
91
143
|
desc = "Re-sends invites to all filtered users that have not accepted the invite as yet"
|
92
144
|
cases.add("-reinvite", :transform, desc, case_name: "reinvite")
|
145
|
+
|
93
146
|
desc = "Re-sends invites to target users that have not accepted the invite as yet"
|
94
147
|
cases.add("-reinvite-from", :sync, desc, case_name: "reinvite")
|
95
148
|
|
@@ -112,8 +165,6 @@ ASSETS.cli.config do |cnf|
|
|
112
165
|
|
113
166
|
desc = "It just adds everybody to an update job without doing any change. If the org has policies, it will refresh"
|
114
167
|
cases.add("-refresh", :transform, desc, case_name: "refresh")
|
115
|
-
desc = "Remaps the abilities of every user based on their usergroups mappings thereof in the org api configuration"
|
116
|
-
cases.add("-refresh-abilities", :transform, desc, case_name: "refresh-abilities")
|
117
168
|
|
118
169
|
desc = "Updates details and core (including supervisor) to target people"
|
119
170
|
cases.add("-update-details-from", :sync, desc, case_name: "update-details")
|
@@ -123,9 +174,10 @@ ASSETS.cli.config do |cnf|
|
|
123
174
|
desc = "Updates the people specified in the input data"
|
124
175
|
cases.add("-update-from", :sync, desc, case_name: "update")
|
125
176
|
|
126
|
-
desc = "Does an actual transfer of
|
127
|
-
cases.add("-transfer-account-from", :sync, desc, case_name: "transfer-account")
|
128
|
-
|
177
|
+
desc = "Does an actual transfer of USER from id|external_id account to 'destination-id' person"
|
178
|
+
cases.add("-transfer-account-from", :sync, desc, case_name: "transfer-account")
|
179
|
+
.add_option("-include-email", "Specifies if the email should also be moved. Otherwise it only moves the account") do |options|
|
180
|
+
options.deep_merge!(include: {email: true})
|
129
181
|
end
|
130
182
|
|
131
183
|
desc = "Tries to find the input entries and update them. It creates them if not found"
|