eco-helpers 2.0.25 → 2.0.30
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 +82 -6
- data/lib/eco/api/common.rb +0 -1
- data/lib/eco/api/common/loaders.rb +2 -0
- data/lib/eco/api/common/loaders/base.rb +58 -0
- data/lib/eco/api/common/loaders/case_base.rb +33 -0
- data/lib/eco/api/common/loaders/error_handler.rb +2 -2
- data/lib/eco/api/common/loaders/parser.rb +30 -5
- data/lib/eco/api/common/loaders/policy.rb +1 -1
- data/lib/eco/api/common/loaders/use_case.rb +1 -1
- data/lib/eco/api/common/people/default_parsers/csv_parser.rb +129 -1
- data/lib/eco/api/common/people/default_parsers/xls_parser.rb +18 -3
- data/lib/eco/api/common/people/entries.rb +83 -14
- data/lib/eco/api/common/people/entry_factory.rb +10 -9
- data/lib/eco/api/common/people/person_attribute_parser.rb +8 -0
- data/lib/eco/api/common/people/person_entry.rb +7 -6
- data/lib/eco/api/common/people/person_entry_attribute_mapper.rb +55 -16
- data/lib/eco/api/common/people/person_factory.rb +4 -2
- data/lib/eco/api/common/people/person_parser.rb +7 -1
- data/lib/eco/api/common/people/supervisor_helpers.rb +1 -1
- data/lib/eco/api/common/version_patches/ecoportal_api/external_person.rb +0 -8
- data/lib/eco/api/common/version_patches/ecoportal_api/internal_person.rb +0 -8
- data/lib/eco/api/microcases/set_core_with_supervisor.rb +4 -2
- data/lib/eco/api/microcases/set_supervisor.rb +29 -8
- data/lib/eco/api/microcases/with_each.rb +7 -3
- data/lib/eco/api/microcases/with_each_starter.rb +3 -2
- data/lib/eco/api/organization/people.rb +1 -1
- data/lib/eco/api/session.rb +7 -2
- data/lib/eco/api/session/batch/job.rb +8 -0
- data/lib/eco/api/usecases/default_cases/create_case.rb +10 -1
- data/lib/eco/api/usecases/default_cases/create_details_case.rb +10 -1
- data/lib/eco/api/usecases/default_cases/create_details_with_supervisor_case.rb +10 -1
- data/lib/eco/api/usecases/default_cases/hris_case.rb +6 -2
- data/lib/eco/api/usecases/default_cases/to_csv_case.rb +1 -37
- data/lib/eco/api/usecases/default_cases/to_csv_detailed_case.rb +42 -0
- data/lib/eco/api/usecases/default_cases/upsert_case.rb +10 -1
- data/lib/eco/cli/config/default/input.rb +2 -2
- data/lib/eco/cli/config/default/options.rb +28 -7
- data/lib/eco/cli/config/default/usecases.rb +16 -0
- data/lib/eco/cli/config/default/workflow.rb +7 -4
- data/lib/eco/cli/config/filters.rb +6 -2
- data/lib/eco/cli/config/filters/input_filters.rb +3 -2
- data/lib/eco/cli/config/filters/people_filters.rb +3 -2
- data/lib/eco/cli/config/help.rb +1 -1
- data/lib/eco/cli/config/options_set.rb +6 -4
- data/lib/eco/cli/config/use_cases.rb +6 -3
- data/lib/eco/csv.rb +2 -0
- data/lib/eco/version.rb +1 -1
- metadata +3 -2
- data/lib/eco/api/common/base_loader.rb +0 -72
@@ -12,9 +12,11 @@ module Eco
|
|
12
12
|
unless options.dig(:exclude, :core) && !person.new?
|
13
13
|
micro.set_core(entry, person, options)
|
14
14
|
if entry.supervisor_id?
|
15
|
-
micro.set_supervisor(entry.supervisor_id,
|
15
|
+
micro.set_supervisor(person, entry.supervisor_id, people, options) do |unknown_id|
|
16
16
|
# delay setting supervisor if does not exit
|
17
|
-
supers_job.add(person)
|
17
|
+
supers_job.add(person) do |person|
|
18
|
+
micro.set_supervisor(person, unknown_id, people, options)
|
19
|
+
end
|
18
20
|
end
|
19
21
|
end
|
20
22
|
end
|
@@ -1,22 +1,27 @@
|
|
1
1
|
module Eco
|
2
2
|
module API
|
3
3
|
class MicroCases
|
4
|
-
#
|
5
|
-
# @note delaying the setting of a `supervisor_id` can save errors when the supervisor still does not exit.
|
6
|
-
# @param sup_id [nil, String] the **supervisor id** we should set on the `person`.
|
4
|
+
# Unique access point to set the `supervisor_id` value on a person.
|
7
5
|
# @param person [Ecoportal::API::V1::Person] the person we want to update, carrying the changes to be done.
|
8
|
-
# @param
|
6
|
+
# @param sup_id [nil, String] the **supervisor id** we should set on the `person`.
|
7
|
+
# @param people [Eco::API::Organization::People] _People_ involved in the current update.
|
9
8
|
# @param options [Hash] the options.
|
10
9
|
# @yield [supervisor_id] callback when the supervisor_id is **unknown** (not `nil` nor any one's in `people`).
|
11
10
|
# @yieldparam supervisor_id [String] the **unknown** `supervisor_id`.
|
12
|
-
def set_supervisor(
|
11
|
+
def set_supervisor(person, sup_id, people, options)
|
13
12
|
unless options.dig(:exclude, :core) || options.dig(:exclude, :supervisor)
|
14
|
-
|
13
|
+
cur_id = person.supervisor_id
|
14
|
+
cur_super = cur_id && with_supervisor(cur_id, people)
|
15
|
+
micro.with_supervisor(sup_id, people) do |new_super|
|
15
16
|
if !sup_id
|
16
17
|
person.supervisor_id = nil
|
17
|
-
|
18
|
-
|
18
|
+
descrease_subordinates(cur_super)
|
19
|
+
elsif new_super && id = new_super.id
|
20
|
+
person.supervisor_id = id
|
21
|
+
descrease_subordinates(cur_super)
|
22
|
+
increase_subordinates(new_super)
|
19
23
|
elsif !block_given?
|
24
|
+
descrease_subordinates(cur_super)
|
20
25
|
person.supervisor_id = sup_id
|
21
26
|
else
|
22
27
|
yield(sup_id) if block_given?
|
@@ -25,6 +30,22 @@ module Eco
|
|
25
30
|
end
|
26
31
|
end
|
27
32
|
|
33
|
+
private
|
34
|
+
|
35
|
+
def descrease_subordinates(person, by = 1)
|
36
|
+
if person.is_a?(Ecoportal::API::V1::Person)
|
37
|
+
person.subordinates -= by
|
38
|
+
#person.subordinates = 0 if person.subordinates < 0
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def increase_subordinates(person, by = 1)
|
43
|
+
if person.is_a?(Ecoportal::API::V1::Person)
|
44
|
+
#person.subordinates = 0 if person.subordinates < 0
|
45
|
+
person.subordinates += by
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
28
49
|
end
|
29
50
|
end
|
30
51
|
end
|
@@ -7,16 +7,20 @@ module Eco
|
|
7
7
|
# @param entries [Eco::API::Common::People::Entries] the input entries with the data.
|
8
8
|
# @param people [Eco::API::Organization::People] target existing _People_ of the current update.
|
9
9
|
# @param options [Hash] the options.
|
10
|
+
# @param append_created [Boolean] whether or not a new person will be added to the `people` object.
|
10
11
|
# @yield [entry, person] gives each entry, and the paired person thereof (new or existing).
|
11
12
|
# @yieldparam entry [PersonEntry] the input entry with the data we should set on person.
|
12
13
|
# @yieldparam person [Ecoportal::API::V1::Person] the found person that matches `entry`, or a new person otherwise.
|
13
14
|
# @return [Eco::API::Organization::People] all the people, including new and existing ones.
|
14
|
-
def with_each(entries, people, options)
|
15
|
+
def with_each(entries, people, options, append_created: true)
|
15
16
|
@_skip_all_multiple_results = false
|
17
|
+
people_copy = people.newFrom(people.to_a)
|
16
18
|
entries.each_with_object([]) do |entry, scoped|
|
17
19
|
begin
|
18
|
-
unless person =
|
19
|
-
person = session.new_person
|
20
|
+
unless person = people_copy.find(entry, strict: micro.strict_search?(options))
|
21
|
+
person = session.new_person.tap do |person|
|
22
|
+
people << person if append_created
|
23
|
+
end
|
20
24
|
end
|
21
25
|
rescue Eco::API::Organization::People::MultipleSearchResults => e
|
22
26
|
unless @_skip_all_multiple_results
|
@@ -8,13 +8,14 @@ module Eco
|
|
8
8
|
# @param people [Eco::API::Organization::People] target existing _People_ of the current update.
|
9
9
|
# @param options [Hash] the options.
|
10
10
|
# @param log_present [Boolean] log error message if an `entry` has match in `people`.
|
11
|
+
# @param append_created [Boolean] whether or not a new person will be added to the `people` object.
|
11
12
|
# @yield [entry, person] gives each **new** `person` of `entries` that is not present in `people`.
|
12
13
|
# @yieldparam entry [PersonEntry] the input entry with the data we should set on person.
|
13
14
|
# @yieldparam person [Ecoportal::API::V1::Person] the **new** person.
|
14
15
|
# @return [Eco::API::Organization::People] the starters.
|
15
|
-
def with_each_starter(entries, people, options, log_present: false)
|
16
|
+
def with_each_starter(entries, people, options, log_present: false, append_created: true)
|
16
17
|
starters = []
|
17
|
-
micro.with_each(entries, people, options) do |entry, person|
|
18
|
+
micro.with_each(entries, people, options, append_created: append_created) do |entry, person|
|
18
19
|
if !person.new?
|
19
20
|
if log_present
|
20
21
|
session.logger.error("This person (id: '#{person.id}') already exists: #{entry.to_s(:identify)}")
|
@@ -258,7 +258,7 @@ module Eco
|
|
258
258
|
|
259
259
|
def init_caches
|
260
260
|
return if @caches_init
|
261
|
-
@by_id = to_h
|
261
|
+
@by_id = no_nil_key(to_h)
|
262
262
|
@by_external_id = no_nil_key(to_h('external_id'))
|
263
263
|
@by_users_email = no_nil_key(existing_users.to_h('email'))
|
264
264
|
@by_non_users_email = no_nil_key(non_users.to_h('email'))
|
data/lib/eco/api/session.rb
CHANGED
@@ -153,9 +153,14 @@ module Eco
|
|
153
153
|
# Generates an entries collection from a csv input file.
|
154
154
|
# @see Eco::API::Common::People::EntryFactory#entries
|
155
155
|
# @param file [String] file to generate the entries from.
|
156
|
+
# @param (see Eco::API::Session#entries)
|
156
157
|
# @return [Eco::API::Common::People::Entries] collection of entries.
|
157
|
-
def csv_entries(file)
|
158
|
-
|
158
|
+
def csv_entries(file, **kargs)
|
159
|
+
kargs.merge!({
|
160
|
+
file: file,
|
161
|
+
format: :csv
|
162
|
+
})
|
163
|
+
return entries(**kargs)
|
159
164
|
end
|
160
165
|
|
161
166
|
# Generates the collection of entries that should be discarded from an update.
|
@@ -304,6 +304,9 @@ module Eco
|
|
304
304
|
if !simulate && status
|
305
305
|
status.queue.map do |entry|
|
306
306
|
if status.success?(entry)
|
307
|
+
if type == :create && entry.respond_to?(:id=)
|
308
|
+
entry.id = status[entry].body["id"]
|
309
|
+
end
|
307
310
|
entry.consolidate! if entry.respond_to?(:consolidate!)
|
308
311
|
#else # do not entry.reset! (keep track on changes still)
|
309
312
|
end
|
@@ -324,7 +327,12 @@ module Eco
|
|
324
327
|
end
|
325
328
|
end
|
326
329
|
elsif simulate
|
330
|
+
fake_id = 111111111111111111111111
|
327
331
|
queue.map do |entry|
|
332
|
+
if type == :create && entry.respond_to?(:id=)
|
333
|
+
entry.id = fake_id.to_s
|
334
|
+
fake_id += 1
|
335
|
+
end
|
328
336
|
entry.consolidate! if entry.respond_to?(:consolidate!)
|
329
337
|
end
|
330
338
|
end
|
@@ -2,12 +2,15 @@ class Eco::API::UseCases::DefaultCases::CreateCase < Eco::API::Common::Loaders::
|
|
2
2
|
name "create"
|
3
3
|
type :sync
|
4
4
|
|
5
|
+
attr_reader :options
|
6
|
+
|
5
7
|
def main(entries, people, session, options, usecase)
|
8
|
+
options = @options
|
6
9
|
micro = session.micro
|
7
10
|
creation = session.new_job("main", "create", :create, usecase)
|
8
11
|
supers = session.new_job("post", "supers", :update, usecase, :core)
|
9
12
|
|
10
|
-
micro.with_each_starter(entries, people, options, log_present: true) do |entry, person|
|
13
|
+
micro.with_each_starter(entries, people, options, log_present: true, append_created: append_created) do |entry, person|
|
11
14
|
creation.add(person)
|
12
15
|
micro.set_core_with_supervisor(entry, person, people, supers, options)
|
13
16
|
entry.set_details(person) unless options.dig(:exclude, :details)
|
@@ -15,4 +18,10 @@ class Eco::API::UseCases::DefaultCases::CreateCase < Eco::API::Common::Loaders::
|
|
15
18
|
end
|
16
19
|
end
|
17
20
|
|
21
|
+
private
|
22
|
+
|
23
|
+
def append_created
|
24
|
+
options.dig(:people, :append_created)
|
25
|
+
end
|
26
|
+
|
18
27
|
end
|
@@ -2,15 +2,24 @@ class Eco::API::UseCases::DefaultCases::CreateDetailsCase < Eco::API::Common::Lo
|
|
2
2
|
name "create-details"
|
3
3
|
type :sync
|
4
4
|
|
5
|
+
attr_reader :options
|
6
|
+
|
5
7
|
def main(entries, people, session, options, usecase)
|
8
|
+
@options = options
|
6
9
|
micro = session.micro
|
7
10
|
creation = session.new_job("main", "create", :create, usecase)
|
8
11
|
|
9
|
-
micro.with_each_starter(entries, people, options, log_present: true) do |entry, person|
|
12
|
+
micro.with_each_starter(entries, people, options, log_present: true, append_created: append_created) do |entry, person|
|
10
13
|
creation.add(person)
|
11
14
|
micro.set_core(entry, person, options)
|
12
15
|
entry.set_details(person) unless options.dig(:exclude, :details)
|
13
16
|
end
|
14
17
|
end
|
15
18
|
|
19
|
+
private
|
20
|
+
|
21
|
+
def append_created
|
22
|
+
options.dig(:people, :append_created)
|
23
|
+
end
|
24
|
+
|
16
25
|
end
|
@@ -2,16 +2,25 @@ class Eco::API::UseCases::DefaultCases::CreateDetailsWithSupervisorCase < Eco::A
|
|
2
2
|
name "create-details-with-supervisor"
|
3
3
|
type :sync
|
4
4
|
|
5
|
+
attr_reader :options
|
6
|
+
|
5
7
|
def main(entries, people, session, options, usecase)
|
8
|
+
@options = options
|
6
9
|
micro = session.micro
|
7
10
|
creation = session.new_job("main", "create", :create, usecase)
|
8
11
|
supers = session.new_job("post", "supers", :update, usecase, :core)
|
9
12
|
|
10
|
-
micro.with_each_starter(entries, people, options, log_present: true) do |entry, person|
|
13
|
+
micro.with_each_starter(entries, people, options, log_present: true, append_created: append_created) do |entry, person|
|
11
14
|
creation.add(person)
|
12
15
|
micro.set_core_with_supervisor(entry, person, people, supers, options)
|
13
16
|
entry.set_details(person) unless options.dig(:exclude, :details)
|
14
17
|
end
|
15
18
|
end
|
16
19
|
|
20
|
+
private
|
21
|
+
|
22
|
+
def append_created
|
23
|
+
options.dig(:people, :append_created)
|
24
|
+
end
|
25
|
+
|
17
26
|
end
|
@@ -18,7 +18,7 @@ class Eco::API::UseCases::DefaultCases::HrisCase < Eco::API::Common::Loaders::Us
|
|
18
18
|
leavers.add(person, &method(:leavers_callback))
|
19
19
|
end
|
20
20
|
|
21
|
-
micro.with_each(entries, people, options) do |entry, person|
|
21
|
+
micro.with_each(entries, people, options, append_created: append_created) do |entry, person|
|
22
22
|
person.new? ? creation.add(person) : update.add(person)
|
23
23
|
micro.set_core_with_supervisor(entry, person, people, supers, options)
|
24
24
|
entry.set_details(person) unless options.dig(:exclude, :details)
|
@@ -28,6 +28,10 @@ class Eco::API::UseCases::DefaultCases::HrisCase < Eco::API::Common::Loaders::Us
|
|
28
28
|
|
29
29
|
private
|
30
30
|
|
31
|
+
def append_created
|
32
|
+
options.dig(:people, :append_created)
|
33
|
+
end
|
34
|
+
|
31
35
|
def leavers_callback(person)
|
32
36
|
person.supervisor_id = nil
|
33
37
|
person.account = nil if person.account
|
@@ -41,7 +45,7 @@ class Eco::API::UseCases::DefaultCases::HrisCase < Eco::API::Common::Loaders::Us
|
|
41
45
|
if other_people.length > 3
|
42
46
|
msg = "There are #{other_people.length} people in schemas other than #{active_schema.name}."
|
43
47
|
msg << " Please, use the filter option '-schema_id SchemaName' for the 'hris' case to only include those of that schema"
|
44
|
-
msg << " in the current update. The HRIS case identifies people that are not in the file as leavers
|
48
|
+
msg << " in the current update. The HRIS case identifies people that are not in the file as leavers"
|
45
49
|
msg << " (as it will remove the account of all the people of other schemas if they are not in the input file)."
|
46
50
|
msg << "\n For example: -schema-id '#{active_schema.name.downcase}'"
|
47
51
|
logger.error(msg)
|
@@ -125,43 +125,7 @@ class Eco::API::UseCases::DefaultCases::ToCsvCase < Eco::API::Common::Loaders::U
|
|
125
125
|
"id" => "ecoPortal ID",
|
126
126
|
"external_id" => "Reference ID (ext_id)",
|
127
127
|
"login_provider_ids" => "Login Methods",
|
128
|
-
"landing_page_id" => "Landing Page ID"
|
129
|
-
"show_sidebar" => "(pref) Sidebar Open?",
|
130
|
-
"show_shortcuts" => "(pref) Link to Registers?",
|
131
|
-
"show_coming_soon" => "(pref) Coming Soon List?",
|
132
|
-
"show_recently_visited_forms" => "(pref) Recently Visited Forms List?",
|
133
|
-
"show_tasks" => "(pref) Tasks List?",
|
134
|
-
"show_task_bubbles" => "(pref) Task Count Bubbles",
|
135
|
-
"kiosk_enabled" => "Kiosk User?",
|
136
|
-
"freemium" => "Freemium User?",
|
137
|
-
"files" => "(able) on Files",
|
138
|
-
"reports" => "(able) on Report Structures",
|
139
|
-
"data" => "(able) on Data (hours, datasets)",
|
140
|
-
"organization" => "(able) on Organization Config",
|
141
|
-
"pages" => "(able) on Page/Entries",
|
142
|
-
"page_editor" => "(able) page Editor Level",
|
143
|
-
"registers" => "(able) on Registers",
|
144
|
-
"tasks" => "(able) on Tasks",
|
145
|
-
"person_core" => "(able) on People",
|
146
|
-
"person_core_create" => "(able) Create People?",
|
147
|
-
"person_core_edit" => "(able) Edit People?",
|
148
|
-
"person_details" => "(able) on People Schema Details",
|
149
|
-
"person_account" => "(able) on Users",
|
150
|
-
"person_abilities" => "(able) on Users' Abilities",
|
151
|
-
"custom_files" => "(min) on Files",
|
152
|
-
"custom_reports" => "(min) on Report Structures",
|
153
|
-
"custom_data" => "(min) on Data (hours, datasets)",
|
154
|
-
"custom_organization" => "(min) on Organization Config",
|
155
|
-
"custom_pages" => "(min) on Page/Entries",
|
156
|
-
"custom_page_editor" => "(min) page Editor Level",
|
157
|
-
"custom_registers" => "(min) on Registers",
|
158
|
-
"custom_tasks" => "(min) on Tasks",
|
159
|
-
"custom_person_core" => "(min) on People",
|
160
|
-
"custom_person_core_create" => "(min) Create People?",
|
161
|
-
"custom_person_core_edit" => "(min) Edit People?",
|
162
|
-
"custom_person_details" => "(min) on People Schema Details",
|
163
|
-
"custom_person_account" => "(min) on Users",
|
164
|
-
"custom_person_abilities" => "(min) on Users' Abilities"
|
128
|
+
"landing_page_id" => "Landing Page ID"
|
165
129
|
}
|
166
130
|
end
|
167
131
|
|
@@ -75,4 +75,46 @@ class Eco::API::UseCases::DefaultCases::ToCsvDetailedCase < Eco::API::UseCases::
|
|
75
75
|
]
|
76
76
|
end
|
77
77
|
|
78
|
+
def nice_header_maps
|
79
|
+
@nice_header_maps ||= super.merge({
|
80
|
+
"landing_page_id" => "Landing Page ID",
|
81
|
+
"show_sidebar" => "(pref) Sidebar Open?",
|
82
|
+
"show_shortcuts" => "(pref) Link to Registers?",
|
83
|
+
"show_coming_soon" => "(pref) Coming Soon List?",
|
84
|
+
"show_recently_visited_forms" => "(pref) Recently Visited Forms List?",
|
85
|
+
"show_tasks" => "(pref) Tasks List?",
|
86
|
+
"show_task_bubbles" => "(pref) Task Count Bubbles",
|
87
|
+
"kiosk_enabled" => "Kiosk User?",
|
88
|
+
"freemium" => "Freemium User?",
|
89
|
+
"files" => "(able) on Files",
|
90
|
+
"reports" => "(able) on Report Structures",
|
91
|
+
"data" => "(able) on Data (hours, datasets)",
|
92
|
+
"organization" => "(able) on Organization Config",
|
93
|
+
"pages" => "(able) on Page/Entries",
|
94
|
+
"page_editor" => "(able) page Editor Level",
|
95
|
+
"registers" => "(able) on Registers",
|
96
|
+
"tasks" => "(able) on Tasks",
|
97
|
+
"person_core" => "(able) on People",
|
98
|
+
"person_core_create" => "(able) Create People?",
|
99
|
+
"person_core_edit" => "(able) Edit People?",
|
100
|
+
"person_details" => "(able) on People Schema Details",
|
101
|
+
"person_account" => "(able) on Users",
|
102
|
+
"person_abilities" => "(able) on Users' Abilities",
|
103
|
+
"custom_files" => "(min) on Files",
|
104
|
+
"custom_reports" => "(min) on Report Structures",
|
105
|
+
"custom_data" => "(min) on Data (hours, datasets)",
|
106
|
+
"custom_organization" => "(min) on Organization Config",
|
107
|
+
"custom_pages" => "(min) on Page/Entries",
|
108
|
+
"custom_page_editor" => "(min) page Editor Level",
|
109
|
+
"custom_registers" => "(min) on Registers",
|
110
|
+
"custom_tasks" => "(min) on Tasks",
|
111
|
+
"custom_person_core" => "(min) on People",
|
112
|
+
"custom_person_core_create" => "(min) Create People?",
|
113
|
+
"custom_person_core_edit" => "(min) Edit People?",
|
114
|
+
"custom_person_details" => "(min) on People Schema Details",
|
115
|
+
"custom_person_account" => "(min) on Users",
|
116
|
+
"custom_person_abilities" => "(min) on Users' Abilities"
|
117
|
+
})
|
118
|
+
end
|
119
|
+
|
78
120
|
end
|
@@ -2,13 +2,16 @@ class Eco::API::UseCases::DefaultCases::UpsertCase < Eco::API::Common::Loaders::
|
|
2
2
|
name "upsert"
|
3
3
|
type :sync
|
4
4
|
|
5
|
+
attr_reader :options
|
6
|
+
|
5
7
|
def main(entries, people, session, options, usecase)
|
8
|
+
@options = options
|
6
9
|
micro = session.micro
|
7
10
|
creation = session.new_job("main", "create", :create, usecase)
|
8
11
|
update = session.new_job("main", "update", :update, usecase)
|
9
12
|
supers = session.new_job("post", "supers", :update, usecase, :core)
|
10
13
|
|
11
|
-
micro.with_each(entries, people, options) do |entry, person|
|
14
|
+
micro.with_each(entries, people, options, append_created: append_created) do |entry, person|
|
12
15
|
person.new? ? creation.add(person) : update.add(person)
|
13
16
|
micro.set_core_with_supervisor(entry, person, people, supers, options)
|
14
17
|
entry.set_details(person) unless options.dig(:exclude, :details)
|
@@ -16,4 +19,10 @@ class Eco::API::UseCases::DefaultCases::UpsertCase < Eco::API::Common::Loaders::
|
|
16
19
|
end
|
17
20
|
end
|
18
21
|
|
22
|
+
private
|
23
|
+
|
24
|
+
def append_created
|
25
|
+
options.dig(:people, :append_created)
|
26
|
+
end
|
27
|
+
|
19
28
|
end
|
@@ -65,8 +65,8 @@ ASSETS.cli.config do |cnf|
|
|
65
65
|
input = [file].flatten.reduce(Eco::API::Organization::People.new([])) do |people, file|
|
66
66
|
people.merge(JSON.parse(File.read(file)))
|
67
67
|
end
|
68
|
-
else
|
69
|
-
input = session.csv_entries(file)
|
68
|
+
else # :csv
|
69
|
+
input = session.csv_entries(file, check_headers: true)
|
70
70
|
end
|
71
71
|
end
|
72
72
|
input
|
@@ -1,19 +1,35 @@
|
|
1
1
|
ASSETS.cli.config do |cnf|
|
2
2
|
cnf.options_set do |options_set, options|
|
3
3
|
options_set.add("--help", "Offers a HELP") do |options, sesssion|
|
4
|
-
conf
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
4
|
+
conf = ASSETS.cli.config
|
5
|
+
active = Proc.new do |opt|
|
6
|
+
if there = SCR.get_arg(opt)
|
7
|
+
refine = SCR.get_arg(opt, with_param: true)
|
8
|
+
end
|
9
|
+
refine || there
|
10
|
+
end
|
11
|
+
|
12
|
+
if hpf = active.call("-filters")
|
13
|
+
puts conf.people_filters.help(refine: hpf)
|
14
|
+
end
|
15
|
+
if hif = active.call("-input-filters")
|
16
|
+
puts conf.input_filters.help(refine: hif)
|
17
|
+
end
|
18
|
+
if ho = active.call("-options")
|
19
|
+
puts conf.options_set.help(refine: ho)
|
20
|
+
end
|
21
|
+
if huc = active.call("-usecases")
|
22
|
+
puts conf.usecases.help(refine: huc)
|
23
|
+
end
|
9
24
|
puts [
|
10
25
|
"Please specify one of the below:",
|
11
26
|
" -filters to display available filters on people",
|
12
27
|
" -input-filters to display available filters on input data",
|
13
28
|
" -options to dislpay available options",
|
14
29
|
" -usecases to display available usecases",
|
15
|
-
"",
|
16
|
-
"You may specify the usecase to know its specific options by:
|
30
|
+
"TIPS:",
|
31
|
+
" * You may specify the usecase to know its specific options by: -usecase_name --help -options",
|
32
|
+
" * You may specify a refinement to show specific information only: --help -usecases tags"
|
17
33
|
].join("\n") unless hpf || hif || ho || huc
|
18
34
|
exit
|
19
35
|
end
|
@@ -87,6 +103,11 @@ ASSETS.cli.config do |cnf|
|
|
87
103
|
session.config.dry_run!
|
88
104
|
end
|
89
105
|
|
106
|
+
desc = "Runs runs post_launch cases even if in dry-run"
|
107
|
+
options_set.add("-run-postlaunch", desc) do |options, session|
|
108
|
+
options.deep_merge!(post_launch: {run: true})
|
109
|
+
end
|
110
|
+
|
90
111
|
desc = "(careful with this option) This will include everybody as part of the update (including those that are api excluded). "
|
91
112
|
desc += "Only launch with this option when only api excluded people are included in your update."
|
92
113
|
options_set.add("-include-excluded", desc) do |options|
|