eco-helpers 2.5.10 → 2.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -2
- data/CHANGELOG.md +64 -4
- data/eco-helpers.gemspec +20 -16
- data/lib/eco/api/common/loaders/base.rb +2 -9
- data/lib/eco/api/common/loaders/use_case.rb +27 -1
- data/lib/eco/api/common/people/default_parsers.rb +2 -2
- data/lib/eco/api/common/people/person_entry.rb +3 -0
- data/lib/eco/api/common/people/person_entry_attribute_mapper.rb +111 -16
- data/lib/eco/api/common/session/base_session.rb +4 -0
- data/lib/eco/api/common/session/environment.rb +4 -0
- data/lib/eco/api/common/session/sftp.rb +1 -1
- data/lib/eco/api/organization/tag_tree.rb +20 -23
- data/lib/eco/api/session/batch/job.rb +4 -4
- data/lib/eco/api/session/batch/jobs.rb +2 -2
- data/lib/eco/api/session/batch/jobs_groups.rb +2 -2
- data/lib/eco/api/session/config/files.rb +2 -2
- data/lib/eco/api/session/config/people.rb +2 -2
- data/lib/eco/api/session/config/sftp.rb +4 -0
- data/lib/eco/api/session/config/tagtree.rb +9 -8
- data/lib/eco/api/session/config/workflow.rb +3 -2
- data/lib/eco/api/session/config.rb +7 -0
- data/lib/eco/api/session.rb +17 -2
- data/lib/eco/api/usecases/cli/dsl.rb +84 -0
- data/lib/eco/api/usecases/cli/option.rb +19 -0
- data/lib/eco/api/usecases/cli.rb +13 -0
- data/lib/eco/api/usecases/default/locations/cli/tagtree_extract_cli.rb +24 -0
- data/lib/eco/api/usecases/{default_cases → default/locations}/codes_to_tags_case.rb +1 -1
- data/lib/eco/api/usecases/{default_cases → default/locations}/create_tag_paths_case.rb +1 -1
- data/lib/eco/api/usecases/{default_cases → default/locations}/csv_to_tree_case.rb +1 -1
- data/lib/eco/api/usecases/default/locations/tagtree_extract_case.rb +173 -0
- data/lib/eco/api/usecases/default/locations.rb +15 -0
- data/lib/eco/api/usecases/{default_cases → default/people}/analyse_people_case.rb +1 -1
- data/lib/eco/api/usecases/{default_cases → default/people}/change_email_case.rb +1 -1
- data/lib/eco/api/usecases/default/people/clean_unknown_tags_case.rb +66 -0
- data/lib/eco/api/usecases/{default_cases → default/people}/clear_abilities_case.rb +1 -1
- data/lib/eco/api/usecases/{default_cases → default/people}/org_data_convert_case.rb +1 -1
- data/lib/eco/api/usecases/{default_cases → default/people}/refresh_case.rb +1 -1
- data/lib/eco/api/usecases/{default_cases → default/people}/reinvite_sync_case.rb +1 -1
- data/lib/eco/api/usecases/{default_cases → default/people}/reinvite_trans_case.rb +1 -1
- data/lib/eco/api/usecases/default/people/reinvite_trans_cli.rb +5 -0
- data/lib/eco/api/usecases/{default_cases → default/people}/restore_db_case.rb +1 -1
- data/lib/eco/api/usecases/{default_cases → default/people}/set_default_tag_case.rb +1 -1
- data/lib/eco/api/usecases/{default_cases → default/people}/supers_cyclic_identify_case.rb +1 -1
- data/lib/eco/api/usecases/{default_cases → default/people}/supers_hierarchy_case.rb +1 -1
- data/lib/eco/api/usecases/{default_cases → default/people}/switch_supervisor_case.rb +1 -1
- data/lib/eco/api/usecases/{default_cases → default/people}/transfer_account_case.rb +1 -1
- data/lib/eco/api/usecases/default/people.rb +25 -0
- data/lib/eco/api/usecases/default.rb +16 -0
- data/lib/eco/api/usecases/default_cases/samples/cli/sftp_cli.rb +46 -0
- data/lib/eco/api/usecases/default_cases/samples/sftp_case.rb +21 -9
- data/lib/eco/api/usecases/default_cases.rb +2 -30
- data/lib/eco/api/usecases/graphql/utils/sftp.rb +1 -1
- data/lib/eco/api/usecases/use_case.rb +21 -7
- data/lib/eco/api/usecases/use_case_chain.rb +2 -2
- data/lib/eco/api/usecases.rb +4 -1
- data/lib/eco/assets.rb +1 -3
- data/lib/eco/cli/config/filters/people_filters.rb +0 -1
- data/lib/eco/cli/config/filters.rb +2 -6
- data/lib/eco/cli/config/help.rb +0 -1
- data/lib/eco/cli/config/input.rb +0 -1
- data/lib/eco/cli/config/options_set.rb +3 -4
- data/lib/eco/cli/config/use_cases.rb +13 -6
- data/lib/eco/cli/config.rb +4 -5
- data/lib/eco/cli/scripting/args_helpers.rb +1 -1
- data/lib/eco/cli/scripting/argument.rb +0 -1
- data/lib/eco/cli/scripting/arguments.rb +0 -2
- data/lib/eco/cli.rb +0 -1
- data/lib/eco/{cli/config/default → cli_default}/input_filters.rb +0 -1
- data/lib/eco/{cli/config/default → cli_default}/people_filters.rb +0 -1
- data/lib/eco/{cli/config/default → cli_default}/usecases.rb +2 -52
- data/lib/eco/{cli/config/default → cli_default}/workflow.rb +3 -2
- data/lib/eco/cli_default.rb +13 -0
- data/lib/eco/csv/table.rb +0 -1
- data/lib/eco/data/files/encoding.rb +1 -1
- data/lib/eco/data/files/helpers.rb +1 -1
- data/lib/eco/data/locations/convert.rb +8 -4
- data/lib/eco/data/locations/node_base/csv_convert.rb +4 -4
- data/lib/eco/data/mapper.rb +6 -1
- data/lib/eco/version.rb +1 -1
- metadata +156 -79
- data/lib/eco/api/usecases/default_cases/abstract_policygroup_abilities_case.rb +0 -160
- data/lib/eco/api/usecases/default_cases/append_usergroups_case.rb +0 -14
- data/lib/eco/api/usecases/default_cases/clean_unknown_tags_case.rb +0 -74
- data/lib/eco/api/usecases/default_cases/create_details_case.rb +0 -20
- data/lib/eco/api/usecases/default_cases/create_details_with_supervisor_case.rb +0 -21
- data/lib/eco/api/usecases/default_cases/email_as_id_case.rb +0 -12
- data/lib/eco/api/usecases/default_cases/new_email_case.rb +0 -13
- data/lib/eco/api/usecases/default_cases/new_id_case.rb +0 -12
- data/lib/eco/api/usecases/default_cases/remove_account_sync_case.rb +0 -10
- data/lib/eco/api/usecases/default_cases/remove_account_trans_case.rb +0 -16
- data/lib/eco/api/usecases/default_cases/reset_landing_page_case.rb +0 -18
- data/lib/eco/api/usecases/default_cases/set_supervisor_case.rb +0 -16
- data/lib/eco/api/usecases/default_cases/tagtree_case.rb +0 -42
- data/lib/eco/api/usecases/default_cases/update_details_case.rb +0 -15
- data/lib/eco/cli/config/default.rb +0 -16
- /data/lib/eco/{cli/config/default → cli_default}/input.rb +0 -0
- /data/lib/eco/{cli/config/default → cli_default}/options.rb +0 -0
- /data/lib/eco/{cli/config/default → cli_default}/people.rb +0 -0
@@ -1,160 +0,0 @@
|
|
1
|
-
class Eco::API::UseCases::DefaultCases::AbstractPolicyGroupAbilities < Eco::API::Common::Loaders::UseCase
|
2
|
-
name "abstract-policygroup-abilities"
|
3
|
-
type :export
|
4
|
-
|
5
|
-
attr_reader :people
|
6
|
-
|
7
|
-
def main(people, session, options, usecase)
|
8
|
-
options[:end_get] = false
|
9
|
-
@people = people
|
10
|
-
|
11
|
-
generate_csv!
|
12
|
-
end
|
13
|
-
|
14
|
-
private
|
15
|
-
|
16
|
-
def file
|
17
|
-
@file ||= options.dig(:output, :file) || "suggested_abilities.csv"
|
18
|
-
end
|
19
|
-
|
20
|
-
def generate_csv!
|
21
|
-
policy_groups.each_with_object({}) do |group, data|
|
22
|
-
data[group.id] ||= {}
|
23
|
-
data[group.id][:name] = group.name
|
24
|
-
data[group.id][:suggested] = group_suggestions(group.id)
|
25
|
-
data[group.id][:percents] = group_abilities(group.id)
|
26
|
-
end.yield_self do |data|
|
27
|
-
abilities_list = Eco::API::Organization::PresetsFactory.abilities
|
28
|
-
CSV.open(file, "w") do |csv|
|
29
|
-
csv << ["Type", "UserGroup", "ID", *abilities_list]
|
30
|
-
# Dump the final suggestions
|
31
|
-
data.each do |id, meta|
|
32
|
-
csv << ["Suggested", meta[:name], id, *meta[:suggested].values_at(*abilities_list)]
|
33
|
-
end
|
34
|
-
# Dump the percentaged levels of each ability
|
35
|
-
data.each do |id, meta|
|
36
|
-
analysis = meta[:percents].values_at(*abilities_list).each_with_object([]) do |levels, values|
|
37
|
-
values << levels.map do |level, percentil|
|
38
|
-
"#{level ? level : "null"} => #{percentil}"
|
39
|
-
end.join("\n")
|
40
|
-
end
|
41
|
-
csv << ["Analysis", meta[:name], id, *analysis]
|
42
|
-
end
|
43
|
-
end
|
44
|
-
puts "Generated file #{file}"
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
def policy_groups
|
49
|
-
@policy_groups ||= session.policy_groups
|
50
|
-
end
|
51
|
-
|
52
|
-
# Suggests 1 final set of abilities for a usergroup
|
53
|
-
def group_suggestions(id)
|
54
|
-
group_abilities(id).each_with_object({}) do |(key, levels), set|
|
55
|
-
data = levels.to_a.sort_by(&:last).reverse.first
|
56
|
-
set[key] = data ? data.shift : nil
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
# Cleans up each ability's levels by:
|
61
|
-
# 1. cutting at some minimum threshold percentage
|
62
|
-
# 2. directly selecting those greater than 70%
|
63
|
-
def group_abilities(id)
|
64
|
-
@group_abilities ||= {}
|
65
|
-
@group_abilities[id] ||= ability_levels_percent(id).each_with_object({}) do |(ability, levels), out|
|
66
|
-
outstanding = nil
|
67
|
-
levels.select do |level, percentil|
|
68
|
-
outstanding ||= level if percentil >= 75
|
69
|
-
percentil > 15
|
70
|
-
end.yield_self do |filtered|
|
71
|
-
out[ability] = outstanding ? filtered.slice(outstanding) : filtered
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
# With given the percentages of sets of abilities
|
77
|
-
# it abstracts the percentage of each level of each ability
|
78
|
-
def ability_levels_percent(id)
|
79
|
-
@ability_levels_percent ||= {}
|
80
|
-
@ability_levels_percent[id] ||= Eco::API::Organization::PresetsFactory.abilities.each_with_object({}) do |key, out|
|
81
|
-
out[key] ||= {}
|
82
|
-
ability_sets_percent(id).each_with_object(out[key]) do |(set, percentil), levels|
|
83
|
-
levels[set[key]] ||= 0
|
84
|
-
levels[set[key]] = (levels[set[key]] + percentil).round(2)
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
# Give a percentage to each set of abilities
|
90
|
-
def ability_sets_percent(id)
|
91
|
-
@ability_sets_percent ||= {}
|
92
|
-
@ability_sets_percent[id] ||= scoped_relevant_raw_data(id).yield_self do |data|
|
93
|
-
# Transform ability sets counter to percentage
|
94
|
-
total = data[:count]
|
95
|
-
abilities = data[:abilities]
|
96
|
-
data[:abilities].transform_values do |val|
|
97
|
-
percent(val, total)
|
98
|
-
end
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
# Get rid of data simingly irrelevant
|
103
|
-
def scoped_relevant_raw_data(id)
|
104
|
-
sp = single_percent(id)
|
105
|
-
sing = single(id); mult = multiple(id)
|
106
|
-
|
107
|
-
# Scope Relevant Raw Data
|
108
|
-
case
|
109
|
-
when sp >= 3 # >= 80
|
110
|
-
sing
|
111
|
-
#when sp < 15
|
112
|
-
# mult
|
113
|
-
else # combine
|
114
|
-
all_abilities = sing[:abilities].keys | mult[:abilities].keys
|
115
|
-
data = {count: sing[:count] + mult[:count], abilities: {}}
|
116
|
-
all_abilities.each_with_object(data) do |abilities, merged|
|
117
|
-
scount = sing[:abilities][abilities] || 0
|
118
|
-
mcount = mult[:abilities][abilities] || 0
|
119
|
-
merged[:abilities][abilities] = scount + mcount
|
120
|
-
end
|
121
|
-
end
|
122
|
-
end
|
123
|
-
|
124
|
-
def single_percent(id)
|
125
|
-
percent(single(id)[:count], count(id))
|
126
|
-
end
|
127
|
-
|
128
|
-
def single(id)
|
129
|
-
groups_abilities.dig(id, :single) || {count: 0, abilities: {}}
|
130
|
-
end
|
131
|
-
|
132
|
-
def multiple(id)
|
133
|
-
groups_abilities.dig(id, :multiple) || {count: 0, abilities: {}}
|
134
|
-
end
|
135
|
-
|
136
|
-
def count(id)
|
137
|
-
groups_abilities.dig(id, :count) || 0
|
138
|
-
end
|
139
|
-
|
140
|
-
def groups_abilities
|
141
|
-
@groups_abilities ||= people.users.each_with_object({}) do |user, groups|
|
142
|
-
abilities = Eco::API::Organization::PresetsFactory.all_abilities(user.account.permissions_custom)
|
143
|
-
ids = user.account.policy_group_ids
|
144
|
-
category = ids.count > 1 ? :multiple : :single
|
145
|
-
|
146
|
-
ids.each do |id|
|
147
|
-
groups[id] ||= {count: 0}
|
148
|
-
groups[id][:count] += 1
|
149
|
-
groups[id][category] ||= {count: 0, abilities: {}}
|
150
|
-
groups[id][category][:count] += 1
|
151
|
-
groups[id][category][:abilities][abilities] ||= 0
|
152
|
-
groups[id][category][:abilities][abilities] += 1
|
153
|
-
end
|
154
|
-
end
|
155
|
-
end
|
156
|
-
|
157
|
-
def percent(num, total)
|
158
|
-
(100 * num.to_f / total).round(2)
|
159
|
-
end
|
160
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
class Eco::API::UseCases::DefaultCases::AppendUsergroupsCase < Eco::API::Common::Loaders::UseCase
|
2
|
-
name "append-usergroups"
|
3
|
-
type :sync
|
4
|
-
|
5
|
-
def main(entries, people, session, options, usecase)
|
6
|
-
micro = session.micro
|
7
|
-
update = session.new_job("main", "update", :update, usecase)
|
8
|
-
|
9
|
-
micro.with_each_present(entries, people, options, log_starter: true) do |entry, person|
|
10
|
-
update.add(person)
|
11
|
-
micro.append_usergroups(entry, person, options)
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
@@ -1,74 +0,0 @@
|
|
1
|
-
class Eco::API::UseCases::DefaultCases::CleanUnknownTags < Eco::API::Common::Loaders::UseCase
|
2
|
-
name "clean-unknown-tags"
|
3
|
-
type :transform
|
4
|
-
|
5
|
-
UNKNOWN_LOCS_FILE = "unknown_locations.txt"
|
6
|
-
|
7
|
-
REGISTER_TAGS = [
|
8
|
-
"EVENT", "INJURY", "RISK", "CONTRACTOR", "PERMIT",
|
9
|
-
"AUDIT", "JSEA",
|
10
|
-
"TRAINING", "INDUCTION",
|
11
|
-
"MEETING", "PPE", "CHEMICAL",
|
12
|
-
"PLANT", "ASSET",
|
13
|
-
"POLICY", "IDEA", "REPORTS"
|
14
|
-
]
|
15
|
-
|
16
|
-
def main(people, session, options, usecase)
|
17
|
-
update = session.new_job("main", "update", :update, usecase)
|
18
|
-
people.each do |person|
|
19
|
-
unknown_tags = person.filter_tags.select {|tag| !tag?(tag)}
|
20
|
-
person.filter_tags -= unknown_tags
|
21
|
-
unknown_tag!(*unknown_tags)
|
22
|
-
if (account = person.account) && tag = account.default_tag
|
23
|
-
unless tag?(tag)
|
24
|
-
micro.refresh_default_tag(person.entry, person, options)
|
25
|
-
unknown_tag!(tag)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
update.add(person)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
private
|
33
|
-
|
34
|
-
def unknown_tag!(*tags)
|
35
|
-
tags.each do |value|
|
36
|
-
unless unknown.include?(value)
|
37
|
-
unknown << value
|
38
|
-
File.open(unknown_tags_file, 'a') do |fd|
|
39
|
-
fd.write("#{value}\n")
|
40
|
-
end
|
41
|
-
puts "Custom detected: '#{value}'"
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
def register_tags
|
47
|
-
REGISTER_TAGS
|
48
|
-
end
|
49
|
-
|
50
|
-
def unknown
|
51
|
-
@unknown ||= []
|
52
|
-
end
|
53
|
-
|
54
|
-
def tag?(value)
|
55
|
-
tagtree.tag?(value).yield_self do |is_loc|
|
56
|
-
next true if is_loc
|
57
|
-
if clean_register_tags?
|
58
|
-
register_tags.any? {|reg| value == reg}
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
def tagtree
|
64
|
-
@tagtree ||= ASSETS.config.tagtree
|
65
|
-
end
|
66
|
-
|
67
|
-
def unknown_tags_file
|
68
|
-
File.join(".","#{session.enviro_name}_#{UNKNOWN_LOCS_FILE}")
|
69
|
-
end
|
70
|
-
|
71
|
-
def clean_register_tags?
|
72
|
-
!options.dig(:usecase, :include_register_tags)
|
73
|
-
end
|
74
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
class Eco::API::UseCases::DefaultCases::CreateDetailsCase < Eco::API::Common::Loaders::UseCase
|
2
|
-
name "create-details"
|
3
|
-
type :sync
|
4
|
-
|
5
|
-
def main(entries, people, session, options, usecase)
|
6
|
-
creation = session.new_job("main", "create", :create, usecase)
|
7
|
-
|
8
|
-
micro.with_each_starter(entries, people, options, log_present: true, append_created: append_created) do |entry, person|
|
9
|
-
creation.add(person)
|
10
|
-
micro.set_core(entry, person, options)
|
11
|
-
entry.set_details(person) unless options.dig(:exclude, :details)
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
private
|
16
|
-
|
17
|
-
def append_created
|
18
|
-
options.dig(:people, :append_created)
|
19
|
-
end
|
20
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
class Eco::API::UseCases::DefaultCases::CreateDetailsWithSupervisorCase < Eco::API::Common::Loaders::UseCase
|
2
|
-
name "create-details-with-supervisor"
|
3
|
-
type :sync
|
4
|
-
|
5
|
-
def main(entries, people, session, options, usecase)
|
6
|
-
creation = session.new_job("main", "create", :create, usecase)
|
7
|
-
supers = session.new_job("post", "supers", :update, usecase, :core)
|
8
|
-
|
9
|
-
micro.with_each_starter(entries, people, options, log_present: true, append_created: append_created) do |entry, person|
|
10
|
-
creation.add(person)
|
11
|
-
micro.set_core_with_supervisor(entry, person, people, supers, options)
|
12
|
-
entry.set_details(person) unless options.dig(:exclude, :details)
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
private
|
17
|
-
|
18
|
-
def append_created
|
19
|
-
options.dig(:people, :append_created)
|
20
|
-
end
|
21
|
-
end
|
@@ -1,12 +0,0 @@
|
|
1
|
-
class Eco::API::UseCases::DefaultCases::EmailAsIdCase < Eco::API::Common::Loaders::UseCase
|
2
|
-
name "email-as-id"
|
3
|
-
type :transform
|
4
|
-
|
5
|
-
def main(people, session, options, usecase)
|
6
|
-
update = session.new_job("main", "update", :update, usecase, :core)
|
7
|
-
people.each do |person|
|
8
|
-
person.external_id = person.email
|
9
|
-
update.add(person)
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
class Eco::API::UseCases::DefaultCases::NewEmailCase < Eco::API::Common::Loaders::UseCase
|
2
|
-
name "new-email"
|
3
|
-
type :sync
|
4
|
-
|
5
|
-
def main(entries, people, session, options, usecase)
|
6
|
-
update = session.new_job("main", "update", :update, usecase, :core)
|
7
|
-
|
8
|
-
micro.with_each_present(entries, people, options, log_starter: true) do |entry, person|
|
9
|
-
update.add(person)
|
10
|
-
person.email = entry.email
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
@@ -1,12 +0,0 @@
|
|
1
|
-
class Eco::API::UseCases::DefaultCases::NewIdCase < Eco::API::Common::Loaders::UseCase
|
2
|
-
name "new-id"
|
3
|
-
type :sync
|
4
|
-
|
5
|
-
def main(entries, people, session, options, usecase)
|
6
|
-
update = session.new_job("main", "update", :update, usecase, :core)
|
7
|
-
micro.with_each_present(entries, people, options, log_starter: true) do |entry, person|
|
8
|
-
update.add(person)
|
9
|
-
person.external_id = entry.external_id
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
@@ -1,10 +0,0 @@
|
|
1
|
-
class Eco::API::UseCases::DefaultCases::RemoveAccountSyncCase < Eco::API::UseCases::DefaultCases::RemoveAccountTransCase
|
2
|
-
name "remove-account"
|
3
|
-
type :sync
|
4
|
-
|
5
|
-
def main(entries, people, session, options, usecase)
|
6
|
-
micro = session.micro
|
7
|
-
found = micro.with_each_present(entries, people, options, log_starter: true)
|
8
|
-
remove_account(found.users)
|
9
|
-
end
|
10
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
class Eco::API::UseCases::DefaultCases::RemoveAccountTransCase < Eco::API::Common::Loaders::UseCase
|
2
|
-
name "remove-account"
|
3
|
-
type :transform
|
4
|
-
|
5
|
-
def remove_account(users)
|
6
|
-
update = session.new_job("main", "update", :update, usecase, :account)
|
7
|
-
users.each do |user|
|
8
|
-
user.account = nil
|
9
|
-
update.add(user)
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
def main(people, session, options, usecase)
|
14
|
-
remove_account(people.users)
|
15
|
-
end
|
16
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
class Eco::API::UseCases::DefaultCases::ResetLandingPageCase < Eco::API::Common::Loaders::UseCase
|
2
|
-
name "reset-landing-page"
|
3
|
-
type :transform
|
4
|
-
|
5
|
-
def main(people, session, options, usecase)
|
6
|
-
update = session.new_job("main", "update", :update, usecase, :core)
|
7
|
-
people.users.each do |user|
|
8
|
-
user.account.landing_page_id = page_id
|
9
|
-
update.add(user)
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
private
|
14
|
-
|
15
|
-
def page_id
|
16
|
-
options[:page_id]
|
17
|
-
end
|
18
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
class Eco::API::UseCases::DefaultCases::SetSupervisorCase < Eco::API::Common::Loaders::UseCase
|
2
|
-
name "set-supervisor"
|
3
|
-
type :sync
|
4
|
-
|
5
|
-
def main(entries, people, session, options, usecase)
|
6
|
-
update = session.new_job("main", "update", :update, usecase)
|
7
|
-
|
8
|
-
micro.with_each_present(entries, people, options, log_starter: true) do |entry, person|
|
9
|
-
if entry.supervisor_id?
|
10
|
-
micro.set_supervisor(person, entry.supervisor_id, people, options) do |unknown_id|
|
11
|
-
session.logger.warn("Supervisor '#{entry.supervisor_id}' does not exist. Entry: #{entry.to_s(:identify)}")
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
class Eco::API::UseCases::DefaultCases::TagTree < Eco::API::Common::Loaders::UseCase
|
2
|
-
name "tagtree"
|
3
|
-
type :other
|
4
|
-
|
5
|
-
def main(session, options, usecase)
|
6
|
-
puts "Use case still in development"
|
7
|
-
exit
|
8
|
-
options[:end_get] = false
|
9
|
-
operations.keys.each do |key|
|
10
|
-
process(key)
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
def process(key)
|
15
|
-
case key
|
16
|
-
when :diff
|
17
|
-
require_graphql_auth!
|
18
|
-
|
19
|
-
when :show_backend
|
20
|
-
require_graphql_auth!
|
21
|
-
|
22
|
-
else
|
23
|
-
logger.warn("Operation #{key} not supported")
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
private
|
28
|
-
|
29
|
-
def require_graphql_auth!
|
30
|
-
unless session.config.api.version_available?(:graphql)
|
31
|
-
logger.error("Missing parameters for to configure a GraphQL connexion.")
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
def operations
|
36
|
-
(options.dig(:tagtree, :operations) || {})
|
37
|
-
end
|
38
|
-
|
39
|
-
def graphql
|
40
|
-
@graphql ||= session.api(version: :graphql)
|
41
|
-
end
|
42
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
class Eco::API::UseCases::DefaultCases::UpdateDetailsCase < Eco::API::Common::Loaders::UseCase
|
2
|
-
name "update-details"
|
3
|
-
type :sync
|
4
|
-
|
5
|
-
def main(entries, people, session, options, usecase)
|
6
|
-
update = session.new_job("main", "update", :update, usecase)
|
7
|
-
supers = session.new_job("post", "supers", :update, usecase, :core)
|
8
|
-
|
9
|
-
micro.with_each_present(entries, people, options, log_starter: true) do |entry, person|
|
10
|
-
update.add(person)
|
11
|
-
micro.set_core_with_supervisor(entry, person, people, supers, options)
|
12
|
-
entry.set_details(person) unless options.dig(:exclude, :details)
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
module Eco
|
2
|
-
class CLI
|
3
|
-
class Config
|
4
|
-
module Default
|
5
|
-
end
|
6
|
-
end
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
require_relative 'default/options'
|
11
|
-
require_relative 'default/input'
|
12
|
-
require_relative 'default/input_filters'
|
13
|
-
require_relative 'default/people'
|
14
|
-
require_relative 'default/people_filters'
|
15
|
-
require_relative 'default/usecases'
|
16
|
-
require_relative 'default/workflow'
|
File without changes
|
File without changes
|
File without changes
|