eco-helpers 2.0.18 → 2.0.24
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 +80 -1
- data/eco-helpers.gemspec +4 -1
- data/lib/eco/api/common/base_loader.rb +9 -5
- data/lib/eco/api/common/loaders/parser.rb +1 -0
- data/lib/eco/api/common/people/default_parsers.rb +1 -0
- data/lib/eco/api/common/people/default_parsers/xls_parser.rb +53 -0
- data/lib/eco/api/common/people/entries.rb +1 -0
- data/lib/eco/api/common/people/entry_factory.rb +88 -23
- data/lib/eco/api/common/people/person_entry.rb +1 -0
- data/lib/eco/api/common/people/person_parser.rb +1 -1
- data/lib/eco/api/common/session.rb +1 -0
- data/lib/eco/api/common/session/base_session.rb +2 -0
- data/lib/eco/api/common/session/helpers.rb +30 -0
- data/lib/eco/api/common/session/helpers/prompt_user.rb +34 -0
- data/lib/eco/api/common/version_patches/ecoportal_api/external_person.rb +1 -1
- data/lib/eco/api/common/version_patches/ecoportal_api/internal_person.rb +7 -4
- data/lib/eco/api/common/version_patches/exception.rb +5 -2
- data/lib/eco/api/microcases/with_each.rb +67 -6
- data/lib/eco/api/microcases/with_each_present.rb +4 -2
- data/lib/eco/api/microcases/with_each_starter.rb +4 -2
- data/lib/eco/api/organization.rb +1 -1
- data/lib/eco/api/organization/people.rb +94 -25
- data/lib/eco/api/organization/people_similarity.rb +272 -0
- data/lib/eco/api/organization/person_schemas.rb +5 -1
- data/lib/eco/api/organization/policy_groups.rb +5 -1
- data/lib/eco/api/organization/tag_tree.rb +33 -0
- data/lib/eco/api/session.rb +19 -8
- data/lib/eco/api/session/batch.rb +7 -5
- data/lib/eco/api/session/batch/job.rb +34 -9
- data/lib/eco/api/usecases.rb +2 -2
- data/lib/eco/api/usecases/base_case.rb +2 -2
- data/lib/eco/api/usecases/base_io.rb +17 -4
- data/lib/eco/api/usecases/default_cases.rb +1 -0
- data/lib/eco/api/usecases/default_cases/analyse_people_case.rb +179 -32
- data/lib/eco/api/usecases/default_cases/clean_unknown_tags_case.rb +37 -0
- data/lib/eco/api/usecases/default_cases/to_csv_case.rb +81 -36
- data/lib/eco/api/usecases/default_cases/to_csv_detailed_case.rb +3 -4
- data/lib/eco/api/usecases/ooze_samples/ooze_update_case.rb +3 -2
- data/lib/eco/cli/config/default/input.rb +61 -8
- data/lib/eco/cli/config/default/options.rb +47 -2
- data/lib/eco/cli/config/default/people.rb +18 -24
- data/lib/eco/cli/config/default/usecases.rb +33 -2
- data/lib/eco/cli/config/default/workflow.rb +12 -7
- data/lib/eco/cli/scripting/args_helpers.rb +2 -2
- data/lib/eco/csv.rb +4 -2
- data/lib/eco/csv/table.rb +121 -21
- data/lib/eco/data/fuzzy_match.rb +109 -27
- data/lib/eco/data/fuzzy_match/chars_position_score.rb +3 -2
- data/lib/eco/data/fuzzy_match/ngrams_score.rb +19 -10
- data/lib/eco/data/fuzzy_match/pairing.rb +12 -19
- data/lib/eco/data/fuzzy_match/result.rb +22 -2
- data/lib/eco/data/fuzzy_match/results.rb +30 -6
- data/lib/eco/data/fuzzy_match/score.rb +12 -7
- data/lib/eco/data/fuzzy_match/string_helpers.rb +14 -1
- data/lib/eco/version.rb +1 -1
- metadata +67 -3
- data/lib/eco/api/organization/people_analytics.rb +0 -60
@@ -0,0 +1,37 @@
|
|
1
|
+
class Eco::API::UseCases::DefaultCases::CleanUnknownTags < Eco::API::Common::Loaders::UseCase
|
2
|
+
name "clean-unknown-tags"
|
3
|
+
type :transform
|
4
|
+
|
5
|
+
REGISTER_TAGS = [
|
6
|
+
"EVENT", "INJURY", "RISK", "CONTRACTOR", "PERMIT",
|
7
|
+
"AUDIT", "JSEA",
|
8
|
+
"TRAINING", "INDUCTION",
|
9
|
+
"MEETING", "PPE", "CHEMICAL",
|
10
|
+
"PLANT", "ASSET",
|
11
|
+
"POLICY", "IDEA", "REPORTS"
|
12
|
+
]
|
13
|
+
|
14
|
+
attr_reader :session, :options
|
15
|
+
|
16
|
+
def main(people, session, options, usecase)
|
17
|
+
@session = session; @options = options
|
18
|
+
|
19
|
+
update = session.new_job("main", "update", :update, usecase)
|
20
|
+
people.each do |person|
|
21
|
+
unknown_tags = person.filter_tags.select {|tag| !tag?(tag)}
|
22
|
+
person.filter_tags -= unknown_tags
|
23
|
+
update.add(person)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def tag?(value)
|
30
|
+
tagtree.tag?(value) || REGISTER_TAGS.any? {|reg| value == reg}
|
31
|
+
end
|
32
|
+
|
33
|
+
def tagtree
|
34
|
+
@tagtree ||= ASSETS.config.tagtree
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
@@ -13,28 +13,42 @@ class Eco::API::UseCases::DefaultCases::ToCsvCase < Eco::API::Common::Loaders::U
|
|
13
13
|
return false
|
14
14
|
end
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
people.each do |person|
|
22
|
-
csv << to_row(person)
|
16
|
+
if options.dig(:export, :options, :split_schemas)
|
17
|
+
by_schema.each do |id, people|
|
18
|
+
sch_name = schemas.to_name(id)
|
19
|
+
prefix = sch_name ? sch_name.gsub(" ", "_") : "No_Schema"
|
20
|
+
create_file!("#{prefix}_#{file}", people)
|
23
21
|
end
|
22
|
+
else
|
23
|
+
create_file!(file, people)
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
27
|
private
|
28
28
|
|
29
|
+
def create_file!(filename = file, data = people)
|
30
|
+
session.logger.info("going to create file: #{filename}")
|
31
|
+
|
32
|
+
CSV.open(filename, "w") do |csv|
|
33
|
+
csv << spot_header(data.first)
|
34
|
+
data.each do |person|
|
35
|
+
csv << to_row(person)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
29
40
|
def to_row(person)
|
30
41
|
entry = to_entry_type(person)
|
31
|
-
entry.values_at(*keys(entry))
|
42
|
+
entry.values_at(*keys(entry)).tap do |row|
|
43
|
+
row << schemas.to_name(person.details&.schema_id) || "No Schema"
|
44
|
+
end
|
32
45
|
end
|
33
46
|
|
34
|
-
def spot_header
|
35
|
-
header = keys(to_entry_type(
|
47
|
+
def spot_header(person = people.first)
|
48
|
+
header = keys(to_entry_type(person))
|
49
|
+
header << "Schema"
|
36
50
|
header = yield(header) if block_given?
|
37
|
-
header = nice_header_names(header) if nice_header_names?
|
51
|
+
header = nice_header_names(header, schema: schema(person.details)) if nice_header_names?
|
38
52
|
header
|
39
53
|
end
|
40
54
|
|
@@ -46,10 +60,62 @@ class Eco::API::UseCases::DefaultCases::ToCsvCase < Eco::API::Common::Loaders::U
|
|
46
60
|
options.dig(:nice_header) || options.dig(:export, :options, :nice_header)
|
47
61
|
end
|
48
62
|
|
49
|
-
def nice_header_names(header)
|
50
|
-
|
63
|
+
def nice_header_names(header, schema: nil)
|
64
|
+
schema ||= session.schema
|
65
|
+
name_maps = schema.fields_by_alt_id.each_with_object({}) do |(alt_id, fld), mappings|
|
51
66
|
mappings[alt_id] = fld.name
|
52
|
-
end.merge(
|
67
|
+
end.merge(nice_header_maps)
|
68
|
+
header.map {|name| name_maps[name] ? name_maps[name] : name}
|
69
|
+
end
|
70
|
+
|
71
|
+
def to_entry_type(person)
|
72
|
+
session.new_entry(person, dependencies: deps).yield_self do |person_entry|
|
73
|
+
options.dig(:export, :options, :internal_names) ? person_entry.mapped_entry : person_entry.external_entry
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def deps
|
78
|
+
@deps ||= {"supervisor_id" => {people: people}}
|
79
|
+
end
|
80
|
+
|
81
|
+
def file
|
82
|
+
@file ||= (options[:file] || options.dig(:export, :file, :name)).tap do |filename|
|
83
|
+
unless filename
|
84
|
+
session.logger.error("Destination file not specified")
|
85
|
+
return false
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
def by_schema
|
91
|
+
people.group_by do |person|
|
92
|
+
if details = person.details
|
93
|
+
details.schema_id
|
94
|
+
end
|
95
|
+
end.transform_values do |persons|
|
96
|
+
people.newFrom persons
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
def schema(value)
|
101
|
+
case value
|
102
|
+
when Ecoportal::API::V1::Person
|
103
|
+
schema(value.details&.schema_id)
|
104
|
+
when String
|
105
|
+
schemas[value]
|
106
|
+
when Ecoportal::API::V1::PersonDetails
|
107
|
+
schema(value.schema_id)
|
108
|
+
when Ecoportal::API::V1::PersonSchema
|
109
|
+
value
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
def schemas
|
114
|
+
session.schemas
|
115
|
+
end
|
116
|
+
|
117
|
+
def nice_header_maps
|
118
|
+
@nice_header_maps ||= {
|
53
119
|
"policy_group_ids" => "User Group(s)",
|
54
120
|
"email" => "Email",
|
55
121
|
"name" => "Name",
|
@@ -96,28 +162,7 @@ class Eco::API::UseCases::DefaultCases::ToCsvCase < Eco::API::Common::Loaders::U
|
|
96
162
|
"custom_person_details" => "(min) on People Schema Details",
|
97
163
|
"custom_person_account" => "(min) on Users",
|
98
164
|
"custom_person_abilities" => "(min) on Users' Abilities"
|
99
|
-
}
|
100
|
-
header.map {|name| name_maps[name] ? name_maps[name] : name}
|
101
|
-
end
|
102
|
-
|
103
|
-
def to_entry_type(person)
|
104
|
-
session.new_entry(person, dependencies: deps).yield_self do |person_entry|
|
105
|
-
options.dig(:export, :options, :internal_names) ? person_entry.mapped_entry : person_entry.external_entry
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
def deps
|
110
|
-
@deps ||= {"supervisor_id" => {people: people}}
|
165
|
+
}
|
111
166
|
end
|
112
167
|
|
113
|
-
def file
|
114
|
-
@file ||= (options[:file] || options.dig(:export, :file, :name)).tap do |filename|
|
115
|
-
unless filename
|
116
|
-
session.logger.error("Destination file not specified")
|
117
|
-
return false
|
118
|
-
end
|
119
|
-
end
|
120
|
-
end
|
121
|
-
|
122
|
-
|
123
168
|
end
|
@@ -5,8 +5,7 @@ class Eco::API::UseCases::DefaultCases::ToCsvDetailedCase < Eco::API::UseCases::
|
|
5
5
|
private
|
6
6
|
|
7
7
|
def to_row(person)
|
8
|
-
|
9
|
-
data = entry.values_at(*keys(entry))
|
8
|
+
data = super(person)
|
10
9
|
data << person.subordinates
|
11
10
|
data << person_supervisor(person)
|
12
11
|
data += user_abilities(person)
|
@@ -38,8 +37,8 @@ class Eco::API::UseCases::DefaultCases::ToCsvDetailedCase < Eco::API::UseCases::
|
|
38
37
|
preferences.map {|key| user_preferences[key] || false}
|
39
38
|
end
|
40
39
|
|
41
|
-
def spot_header
|
42
|
-
super do |header|
|
40
|
+
def spot_header(person = people.first)
|
41
|
+
super(person) do |header|
|
43
42
|
header << "Subordinates"
|
44
43
|
header << "Supervisor Name"
|
45
44
|
header += abilities_header
|
@@ -124,8 +124,9 @@ class Eco::API::UseCases::OozeSamples::OozeUpdateCase < Eco::API::Common::Loader
|
|
124
124
|
end
|
125
125
|
|
126
126
|
def prompt_to_confirm!
|
127
|
-
|
128
|
-
|
127
|
+
prompt_user("Do you want to proceed (y/N)?", default: "Y") do |response|
|
128
|
+
exit(1) unless response.upcase.start_with?("Y")
|
129
|
+
end
|
129
130
|
end
|
130
131
|
|
131
132
|
end
|
@@ -1,18 +1,71 @@
|
|
1
1
|
ASSETS.cli.config do |cnf|
|
2
|
+
formats = {
|
3
|
+
csv: {
|
4
|
+
option: ["-csv"],
|
5
|
+
extname: [".csv", ".txt"]
|
6
|
+
},
|
7
|
+
xml: {
|
8
|
+
option: ["-xml"],
|
9
|
+
extname: [".xml"]
|
10
|
+
},
|
11
|
+
xls: {
|
12
|
+
option: ["-xls", "-xlsx", "-excel"],
|
13
|
+
extname: [".xls", ".xlsx", ".xlsm"]
|
14
|
+
},
|
15
|
+
json: {
|
16
|
+
option: ["-json"],
|
17
|
+
extname: [".json"]
|
18
|
+
}
|
19
|
+
}
|
20
|
+
|
2
21
|
cnf.input(default_option: "-entries-from") do |session, str_opt, options|
|
3
22
|
input = []
|
4
23
|
if SCR.get_arg(str_opt)
|
5
24
|
file = SCR.get_file(str_opt, required: true)
|
25
|
+
|
26
|
+
# Command line check
|
27
|
+
format = formats.reduce(nil) do |matched, (format, selectors)|
|
28
|
+
used = selectors[:option].reduce(false) {|used, option| SCR.get_arg(option) || used}
|
29
|
+
next matched if matched
|
30
|
+
next format if used
|
31
|
+
end
|
32
|
+
|
33
|
+
# File/Folder check
|
34
|
+
file = File.expand_path(file)
|
35
|
+
if File.directory?(file)
|
36
|
+
folder = file
|
37
|
+
file = Dir.glob("#{file}/*").reject {|f| File.directory?(f)}
|
38
|
+
ext = (format && formats[format][:extname]) || [File.extname(file.first)]
|
39
|
+
file = file.select {|f| ext.any? {|e| File.extname(f) == e}}.tap do |files|
|
40
|
+
if files.empty?
|
41
|
+
session.logger.error("Could not find any file with extension: #{ext} in folder '#{folder}'")
|
42
|
+
exit(1)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
else
|
46
|
+
ext = File.extname(file)
|
47
|
+
end
|
48
|
+
|
49
|
+
format ||= formats.reduce(nil) do |matched, (format, selectors)|
|
50
|
+
next matched if matched
|
51
|
+
next format if selectors[:extname].any? {|e| ext == e}
|
52
|
+
end
|
53
|
+
format ||= :csv
|
54
|
+
|
6
55
|
options.deep_merge!(input: {file: {name: file}})
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
56
|
+
options.deep_merge!(input: {file: {format: format}})
|
57
|
+
|
58
|
+
case format
|
59
|
+
when :xml
|
60
|
+
[file].flatten.each {|f| session.config.files.validate(:xml, f)}
|
61
|
+
input = session.entries(file: file, format: format)
|
62
|
+
when :xls
|
63
|
+
input = session.entries(file: file, format: format)
|
64
|
+
when :json
|
65
|
+
input = [file].flatten.reduce(Eco::API::Organization::People.new([])) do |people, file|
|
66
|
+
people.merge(JSON.parse(File.read(file)))
|
67
|
+
end
|
14
68
|
else
|
15
|
-
options.deep_merge!(input: {file: {format: :csv}})
|
16
69
|
input = session.csv_entries(file)
|
17
70
|
end
|
18
71
|
end
|
@@ -18,6 +18,12 @@ ASSETS.cli.config do |cnf|
|
|
18
18
|
exit
|
19
19
|
end
|
20
20
|
|
21
|
+
desc = "Redirect Standard Ouput to file"
|
22
|
+
options_set.add("-stdout", desc) do |options, session|
|
23
|
+
file = SCR.get_arg("-stdout", with_param: true) || "output.txt"
|
24
|
+
STDOUT.reopen(file, "w+")
|
25
|
+
end
|
26
|
+
|
21
27
|
desc = "Fix the current session to work with this schema"
|
22
28
|
options_set.add("-schema-id", desc) do |options, session|
|
23
29
|
sch_name = SCR.get_arg("-schema-id", with_param: true)
|
@@ -35,11 +41,24 @@ ASSETS.cli.config do |cnf|
|
|
35
41
|
session.schema = sch_id
|
36
42
|
end
|
37
43
|
|
38
|
-
desc
|
44
|
+
desc = "Used to be used to specify the input file or folder when using -get-partial."
|
45
|
+
desc += "It can also be useful to obtain `-get-partial` of people base on `:export` use cases (i.e. -people-to-csv)"
|
39
46
|
options_set.add("-entries-from", desc) do |options, session|
|
40
47
|
options.deep_merge!(input: {entries_from: true})
|
41
48
|
end
|
42
49
|
|
50
|
+
desc = "Used to only get the people from the input file. It will also include their current and new supervisors."
|
51
|
+
options_set.add("-get-partial", desc) do |options, session|
|
52
|
+
options.deep_merge!(people: {
|
53
|
+
get: {from: :remote, type: :partial}
|
54
|
+
})
|
55
|
+
end
|
56
|
+
|
57
|
+
desc = "Do not load any people for this run."
|
58
|
+
options_set.add("-no-people", desc) do |options, session|
|
59
|
+
options.deep_merge!(people: {get: false})
|
60
|
+
end
|
61
|
+
|
43
62
|
desc = "Locally cache all the people manager by retrieving from the server"
|
44
63
|
options_set.add("-get-people", desc) do |options, session|
|
45
64
|
options.deep_merge!(people: {
|
@@ -47,12 +66,38 @@ ASSETS.cli.config do |cnf|
|
|
47
66
|
})
|
48
67
|
end
|
49
68
|
|
50
|
-
|
69
|
+
desc = "Saves the requests's body even though running in dry-run (-simulate)"
|
70
|
+
options_set.add("-save-requests", desc) do |options, session|
|
71
|
+
options.deep_merge!(requests: {backup: true})
|
72
|
+
end
|
73
|
+
|
74
|
+
desc = "Used to specify the cache file of people to be used. "
|
75
|
+
desc += "It is useful to use as people reference those stored in cached file diffrent to the last one."
|
76
|
+
options_set.add("-people-from-backup", desc) do |options, session|
|
77
|
+
file = SCR.get_file("-people-from-backup", required: true, should_exist: true)
|
78
|
+
options.deep_merge!(people: {
|
79
|
+
get: {from: :local, type: :file, file: file}
|
80
|
+
})
|
81
|
+
end
|
82
|
+
|
83
|
+
desc = "Runs in dry-run (no requests sent to server)"
|
84
|
+
options_set.add(["-dry-run", "-simulate"], desc) do |options, session|
|
51
85
|
options[:dry_run] = true
|
52
86
|
options[:simulate] = true
|
53
87
|
session.config.dry_run!
|
54
88
|
end
|
55
89
|
|
90
|
+
desc = "(careful with this option) This will include everybody as part of the update (including those that are api excluded). "
|
91
|
+
desc += "Only launch with this option when only api excluded people are included in your update."
|
92
|
+
options_set.add("-include-excluded", desc) do |options|
|
93
|
+
options.deep_merge!(include: {excluded: true})
|
94
|
+
end
|
95
|
+
|
96
|
+
desc = "Includes in API updates ONLY people that evaluate true as people excluded from periodic upates."
|
97
|
+
options_set.add("-include-only-excluded", desc) do |options|
|
98
|
+
options.deep_merge!(include: {only_excluded: true})
|
99
|
+
end
|
100
|
+
|
56
101
|
desc = "Ignores threshold limitations on requests for this session (skip batch belt)"
|
57
102
|
options_set.add("-skip-batch-policy", desc) do |options|
|
58
103
|
options.deep_merge!(skip: {batch_policy: true})
|
@@ -1,29 +1,23 @@
|
|
1
1
|
ASSETS.cli.config do |cnf|
|
2
2
|
cnf.people do |input, session, options|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
people
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
options.deep_merge!(people: {
|
14
|
-
get: {from: :local, type: :backup}
|
15
|
-
})
|
16
|
-
people = JSON.parse(File.read(file))
|
17
|
-
people = Eco::API::Organization::People.new(people)
|
18
|
-
elsif SCR.get_arg("-get-partial")
|
19
|
-
unless input && input.is_a?(Enumerable)
|
3
|
+
get = options.dig(:people, :get) || {}
|
4
|
+
case
|
5
|
+
when get == false
|
6
|
+
Eco::API::Organization::People.new([])
|
7
|
+
when (get[:from] == :remote) && get[:type] == :full
|
8
|
+
# -get-people
|
9
|
+
session.micro.people_cache
|
10
|
+
when (get[:from] == :remote) && get[:type] == :partial
|
11
|
+
# -get-partial
|
12
|
+
unless (input && input.is_a?(Enumerable))
|
20
13
|
raise "To use -get-partial (partial updates), you need to use -entries-from"
|
21
14
|
end
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
people =
|
15
|
+
session.micro.people_search(input, options: options)
|
16
|
+
when (get[:from] == :local) && get[:type] == :file
|
17
|
+
# -people-from-backup
|
18
|
+
session.micro.people_load(get[:file], modifier: :file)
|
19
|
+
#people = JSON.parse(File.read(get[:file]))
|
20
|
+
#Eco::API::Organization::People.new(people)
|
27
21
|
else
|
28
22
|
options.deep_merge!(people: {
|
29
23
|
get: {from: :local, type: :full}
|
@@ -33,9 +27,9 @@ ASSETS.cli.config do |cnf|
|
|
33
27
|
options.deep_merge!(people: {
|
34
28
|
get: {from: :remote, type: :full}
|
35
29
|
})
|
36
|
-
people = session.micro.people_cache
|
30
|
+
people = session.micro.people_cache
|
37
31
|
end
|
32
|
+
people
|
38
33
|
end
|
39
|
-
people
|
40
34
|
end
|
41
35
|
end
|
@@ -26,11 +26,36 @@ ASSETS.cli.config do |cnf|
|
|
26
26
|
end
|
27
27
|
|
28
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: "
|
29
|
+
cases.add("-analyse-people", :export, desc, case_name: "analyse-people") do |people, session, options|
|
30
30
|
options.deep_merge!(output: {file: "people_analysis.txt"}) unless options.dig(:output, :file)
|
31
|
-
|
31
|
+
#unless options.dig(:usecase, :analyse_people, :use_field)
|
32
|
+
# options.deep_merge!(usecase: {analyse_people: {use_field: :name}})
|
33
|
+
#end
|
34
|
+
end.add_option("-to", "Specify the output file.") do |options|
|
32
35
|
file = SCR.get_file("-to", required: true, should_exist: false)
|
33
36
|
options.deep_merge!(output: {file: file})
|
37
|
+
end.add_option("-identify-duplicates", "Generates a list of people with possible duplicates.") do |options|
|
38
|
+
options.deep_merge!(usecase: {analyse_people: {identify_duplicates: true}})
|
39
|
+
end.add_option("-use-field", "Works with -identify-duplicates. Sets field to be used in the comparison.") do |options|
|
40
|
+
expression = SCR.get_arg("-use-field", with_param: true)
|
41
|
+
options.deep_merge!(usecase: {analyse_people: {use_field: expression}})
|
42
|
+
end.add_option("-facet-field", "Works with -identify-duplicates. Adds an additional layer of comparison.") do |options|
|
43
|
+
expression = SCR.get_arg("-facet-field", with_param: true)
|
44
|
+
options.deep_merge!(usecase: {analyse_people: {facet_field: expression}})
|
45
|
+
end.add_option("-only-screening", "Works with -identify-duplicates. Skips the rearrangement stage.") do |options|
|
46
|
+
options.deep_merge!(usecase: {analyse_people: {only_screening: true}})
|
47
|
+
end.add_option("-ignore-matching-words", "Works with -identify-duplicates. Re-adjust scores ignoring matching words.") do |options|
|
48
|
+
options.deep_merge!(usecase: {analyse_people: {ignore_matching_words: true}})
|
49
|
+
end.add_option("-unique-words", "Works with -identify-duplicates. Re-adjust the comparing strings to do not have repeated words.") do |options|
|
50
|
+
options.deep_merge!(usecase: {analyse_people: {unique_words: true}})
|
51
|
+
end.add_option("-identify-unnamed", "Identifies all people with no names.") do |options|
|
52
|
+
options.deep_merge!(usecase: {analyse_people: {identify_unnamed: true}})
|
53
|
+
end.add_option("-backup-people-results", "Generates a json file with all the people involved in the final results of the analysis.") do |options|
|
54
|
+
file = SCR.get_file("-backup-people-results", required: true, should_exist: false)
|
55
|
+
options.deep_merge!(usecase: {analyse_people: {backup_people: File.expand_path(file)}})
|
56
|
+
end.add_option("-to-csv", "Genarates a CSV file with all people of the final results.") do |options|
|
57
|
+
file = SCR.get_file("-to-csv", required: true, should_exist: false) || "Results.csv"
|
58
|
+
options.deep_merge!(usecase: {analyse_people: {csv_file: File.expand_path(file)}})
|
34
59
|
end
|
35
60
|
|
36
61
|
desc = "It exports to a CSV the (filtered) people"
|
@@ -48,6 +73,8 @@ ASSETS.cli.config do |cnf|
|
|
48
73
|
options.deep_merge!(export: {options: {detailed: true}})
|
49
74
|
end.add_option("-permissions-custom", "Used with -detailed. Adds the permissions_custom abilities") do |options|
|
50
75
|
options.deep_merge!(export: {options: {permissions_custom: true}})
|
76
|
+
end.add_option("-split-schemas", "It will generate 1 file per each schema") do |options|
|
77
|
+
options.deep_merge!(export: {options: {split_schemas: true}})
|
51
78
|
end
|
52
79
|
|
53
80
|
desc = "Adds a column 'ecoPortalTag' to the input CSV with the tags that the location codes map to"
|
@@ -60,6 +87,10 @@ ASSETS.cli.config do |cnf|
|
|
60
87
|
options.deep_merge!(other: {file: {codes_column: col_codes}})
|
61
88
|
end
|
62
89
|
|
90
|
+
desc = "Cleans from filter_tags those tags that are not present in the tagtree (as per tagtree.json file)."
|
91
|
+
desc += " It will preserve standard register tags of most common registers (i.e. EVENT, RISK)."
|
92
|
+
cases.add("-clean-unknown-tags", :transform, desc, case_name: "clean-unknown-tags")
|
93
|
+
|
63
94
|
desc = "Removes the landing page or sets it to -page-id"
|
64
95
|
cases.add("-reset-landing-page", :transform, desc, case_name: "reset-landing-page")
|
65
96
|
.add_option("-page-id", "Target landing page to set to the users") do |options|
|