eco-helpers 0.9.2 → 0.9.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (92) hide show
  1. checksums.yaml +4 -4
  2. data/lib/eco/api.rb +1 -0
  3. data/lib/eco/api/common.rb +1 -0
  4. data/lib/eco/api/common/class_helpers.rb +33 -0
  5. data/lib/eco/api/common/people.rb +1 -0
  6. data/lib/eco/api/common/people/person_attribute_parser.rb +52 -0
  7. data/lib/eco/api/common/people/person_entry_attribute_mapper.rb +2 -2
  8. data/lib/eco/api/common/people/person_parser.rb +16 -10
  9. data/lib/eco/api/common/version_patches.rb +2 -3
  10. data/lib/eco/api/common/version_patches/ecoportal_api.rb +4 -0
  11. data/lib/eco/api/common/version_patches/{base_model.rb → ecoportal_api/base_model.rb} +0 -0
  12. data/lib/eco/api/common/version_patches/{external_person.rb → ecoportal_api/external_person.rb} +0 -0
  13. data/lib/eco/api/common/version_patches/{internal_person.rb → ecoportal_api/internal_person.rb} +0 -0
  14. data/lib/eco/api/common/version_patches/hash.rb +2 -0
  15. data/lib/eco/api/common/version_patches/hash/deep_merge.rb +34 -0
  16. data/lib/eco/api/error.rb +133 -0
  17. data/lib/eco/api/error/handler.rb +19 -0
  18. data/lib/eco/api/error/handlers.rb +22 -0
  19. data/lib/eco/api/organization/people.rb +11 -11
  20. data/lib/eco/api/organization/policy_groups.rb +8 -0
  21. data/lib/eco/api/policies.rb +26 -3
  22. data/lib/eco/api/policies/policy.rb +4 -5
  23. data/lib/eco/api/session.rb +27 -18
  24. data/lib/eco/api/session/batch.rb +12 -6
  25. data/lib/eco/api/session/batch/errors.rb +134 -0
  26. data/lib/eco/api/session/batch/job.rb +213 -0
  27. data/lib/eco/api/session/batch/jobs.rb +72 -0
  28. data/lib/eco/api/session/batch/jobs_groups.rb +85 -0
  29. data/lib/eco/api/session/batch/status.rb +133 -0
  30. data/lib/eco/api/session/config.rb +36 -14
  31. data/lib/eco/api/session/config/base_config.rb +2 -0
  32. data/lib/eco/api/session/config/people.rb +8 -0
  33. data/lib/eco/api/session/config/post_launch.rb +58 -0
  34. data/lib/eco/api/session/config/workflow.rb +189 -0
  35. data/lib/eco/api/session/task.rb +49 -6
  36. data/lib/eco/api/usecases.rb +137 -2
  37. data/lib/eco/api/usecases/base_case.rb +20 -8
  38. data/lib/eco/api/usecases/base_io.rb +97 -0
  39. data/lib/eco/api/usecases/default_case.rb +19 -0
  40. data/lib/eco/api/usecases/default_cases.rb +2 -2
  41. data/lib/eco/api/usecases/default_cases/change_email_case.rb +2 -2
  42. data/lib/eco/api/usecases/default_cases/create_case.rb +2 -2
  43. data/lib/eco/api/usecases/default_cases/create_details_case.rb +2 -2
  44. data/lib/eco/api/usecases/default_cases/create_details_with_supervisor_case.rb +2 -2
  45. data/lib/eco/api/usecases/default_cases/delete_case.rb +2 -2
  46. data/lib/eco/api/usecases/default_cases/email_as_id_case.rb +2 -2
  47. data/lib/eco/api/usecases/default_cases/hris_case.rb +2 -2
  48. data/lib/eco/api/usecases/default_cases/new_email_case.rb +2 -2
  49. data/lib/eco/api/usecases/default_cases/new_id_case.rb +2 -2
  50. data/lib/eco/api/usecases/default_cases/recover_db_case.rb +11 -8
  51. data/lib/eco/api/usecases/default_cases/refresh_presets_case.rb +2 -2
  52. data/lib/eco/api/usecases/default_cases/reinvite_case.rb +2 -2
  53. data/lib/eco/api/usecases/default_cases/remove_account_case.rb +2 -2
  54. data/lib/eco/api/usecases/default_cases/reset_landing_page_case.rb +2 -2
  55. data/lib/eco/api/usecases/default_cases/set_default_tag_case.rb +2 -2
  56. data/lib/eco/api/usecases/default_cases/set_supervisor_case.rb +2 -2
  57. data/lib/eco/api/usecases/default_cases/switch_supervisor_case.rb +2 -2
  58. data/lib/eco/api/usecases/default_cases/to_csv_case.rb +4 -4
  59. data/lib/eco/api/usecases/default_cases/to_csv_detailed_case.rb +3 -3
  60. data/lib/eco/api/usecases/default_cases/update_case.rb +2 -2
  61. data/lib/eco/api/usecases/default_cases/update_details_case.rb +2 -2
  62. data/lib/eco/api/usecases/default_cases/upsert_case.rb +2 -2
  63. data/lib/eco/api/usecases/use_case.rb +23 -36
  64. data/lib/eco/api/usecases/use_case_chain.rb +14 -24
  65. data/lib/eco/api/usecases/use_case_io.rb +23 -75
  66. data/lib/eco/assets.rb +11 -11
  67. data/lib/eco/cli.rb +37 -0
  68. data/lib/eco/cli/config.rb +63 -1
  69. data/lib/eco/cli/config/default.rb +15 -0
  70. data/lib/eco/cli/config/default/filters.rb +69 -0
  71. data/lib/eco/cli/config/default/input.rb +21 -0
  72. data/lib/eco/cli/config/default/options.rb +47 -0
  73. data/lib/eco/cli/config/default/people.rb +39 -0
  74. data/lib/eco/cli/config/default/usecases.rb +63 -0
  75. data/lib/eco/cli/config/default/workflow.rb +86 -0
  76. data/lib/eco/cli/config/input.rb +40 -0
  77. data/lib/eco/cli/config/options_set.rb +35 -0
  78. data/lib/eco/cli/config/people_filters.rb +38 -0
  79. data/lib/eco/cli/config/use_cases.rb +87 -0
  80. data/lib/eco/cli/scripting/args_helpers.rb +10 -4
  81. data/lib/eco/cli/scripting/argument.rb +6 -0
  82. data/lib/eco/language/models/collection.rb +1 -0
  83. data/lib/eco/version.rb +1 -1
  84. metadata +32 -12
  85. data/lib/eco/api/policies/base_policy.rb +0 -14
  86. data/lib/eco/api/policies/used_policies.rb +0 -37
  87. data/lib/eco/api/session/batch_job.rb +0 -215
  88. data/lib/eco/api/session/batch_jobs.rb +0 -62
  89. data/lib/eco/api/session/batch_status.rb +0 -205
  90. data/lib/eco/api/session/job_groups.rb +0 -75
  91. data/lib/eco/api/usecases/use_group.rb +0 -124
  92. data/lib/eco/cli/config/options.rb +0 -11
@@ -0,0 +1,87 @@
1
+ module Eco
2
+ class CLI
3
+ class Config
4
+ class UseCases
5
+
6
+ attr_reader :core_config
7
+
8
+ def initialize(core_config:)
9
+ @core_config = core_config
10
+ @linked_cases = {}
11
+ end
12
+
13
+ def add(option_case, type, case_name: nil)
14
+ Eco::API::UseCases::UseCase.validate_type(type)
15
+ unless callback = block_given?? Proc.new : nil
16
+ raise "You must specify a valid 'case_name' when no block is provided" unless case_name
17
+ raise "'case_name' expected to be a String. Given: #{case_name.class}" unless case_name.is_a?(String)
18
+ end
19
+
20
+ @linked_cases[option_case] = {
21
+ type => {
22
+ casename: case_name,
23
+ callback: callback
24
+ }
25
+ }
26
+ self
27
+ end
28
+
29
+ def process(io:)
30
+ unless io && io.is_a?(Eco::API::UseCases::BaseIO)
31
+ raise "You need to provide Eco::API::UseCases::BaseIO object. Given: #{io.class}"
32
+ end
33
+
34
+ processed = false
35
+ @linked_cases.each do |option, types|
36
+ types.each do |type, data|
37
+ if SCR.get_arg(option)
38
+ processed = true
39
+ io = solve_io(io: io, type: type, option: option)
40
+
41
+ usecase = nil
42
+ if case_name = data[:casename]
43
+ usecase = io.session.usecases.case(case_name, type: type)
44
+ end
45
+
46
+ if callback = data[:callback]
47
+ if usecase
48
+ callback.call(*io.params)
49
+ else
50
+ usecase = callback.call(*io.params)
51
+ unless usecase.is_a?(Eco::API::UseCases::UseCase)
52
+ msg = "When adding a usecase, without specifying 'case_name:', "
53
+ msg += "the block that integrates usecase for cli option '#{option}'"
54
+ msg += " must return an Eco::API::UseCases::UseCase object. It returns #{usecase.class}"
55
+ raise msg
56
+ end
57
+ end
58
+ end
59
+
60
+ usecase.launch(io: io)
61
+ end
62
+ end
63
+ end
64
+ processed
65
+ end
66
+
67
+ private
68
+
69
+ def solve_io(io:, type:, option:)
70
+ params = io.params(keyed: true).merge(type: type)
71
+
72
+ if (!io.people || io.people.empty?) && io.class.people_required?(type)
73
+ params.merge!(people: core_config.people)
74
+ end
75
+
76
+ if (!io.input || io.input.empty?) && io.class.input_required?(type)
77
+ input = core_config.input.get(io: io, option: option)
78
+ params.merge!(input: input)
79
+ end
80
+
81
+ io.new(**params)
82
+ end
83
+
84
+ end
85
+ end
86
+ end
87
+ end
@@ -4,16 +4,22 @@ module Eco
4
4
  module ArgsHelpers
5
5
 
6
6
  def is_modifier?(value)
7
- value&.start_with?("-")
7
+ Argument.is_modifier?(value)
8
8
  end
9
9
 
10
10
  def arguments
11
11
  @arguments ||= Arguments.new
12
12
  end
13
13
 
14
- def stop_on_unknown!(exclude: [])
15
- if arguments.any_unkown?(exclude: exclude)
16
- raise "There are unknown options in your command line arguments: #{arguments.unknown(exclude: exclude)}"
14
+ def stop_on_unknown!(exclude: [], only_options: false)
15
+ # validate only those that are options
16
+ unknown = arguments.unknown(exclude: exclude)
17
+ if only_options
18
+ unknown = unknown..select {|arg| is_modifier?(arg)}
19
+ end
20
+
21
+ unless unknown.empty?
22
+ raise "There are unknown options in your command line arguments: #{unknown}"
17
23
  end
18
24
  end
19
25
 
@@ -5,6 +5,12 @@ module Eco
5
5
 
6
6
  attr_reader :key
7
7
 
8
+ class << self
9
+ def is_modifier?(value)
10
+ value&.start_with?("-")
11
+ end
12
+ end
13
+
8
14
  def initialize(key, with_param: false)
9
15
  @key = key
10
16
  @with_param = !!with_param
@@ -50,6 +50,7 @@ module Eco
50
50
  end
51
51
 
52
52
  def merge(data)
53
+ data = data.to_a unless data.is_a?(Array)
53
54
  newFrom to_a + data
54
55
  end
55
56
 
data/lib/eco/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Eco
2
- VERSION = "0.9.2"
2
+ VERSION = "0.9.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eco-helpers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.2
4
+ version: 0.9.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oscar Segura
@@ -235,6 +235,7 @@ files:
235
235
  - lib/eco-helpers.rb
236
236
  - lib/eco/api.rb
237
237
  - lib/eco/api/common.rb
238
+ - lib/eco/api/common/class_helpers.rb
238
239
  - lib/eco/api/common/people.rb
239
240
  - lib/eco/api/common/people/base_parser.rb
240
241
  - lib/eco/api/common/people/default_parsers.rb
@@ -246,6 +247,7 @@ files:
246
247
  - lib/eco/api/common/people/default_parsers/select_parser.rb
247
248
  - lib/eco/api/common/people/entries.rb
248
249
  - lib/eco/api/common/people/entry_factory.rb
250
+ - lib/eco/api/common/people/person_attribute_parser.rb
249
251
  - lib/eco/api/common/people/person_entry.rb
250
252
  - lib/eco/api/common/people/person_entry_attribute_mapper.rb
251
253
  - lib/eco/api/common/people/person_factory.rb
@@ -259,10 +261,16 @@ files:
259
261
  - lib/eco/api/common/session/mailer.rb
260
262
  - lib/eco/api/common/session/s3_uploader.rb
261
263
  - lib/eco/api/common/version_patches.rb
262
- - lib/eco/api/common/version_patches/base_model.rb
263
- - lib/eco/api/common/version_patches/external_person.rb
264
- - lib/eco/api/common/version_patches/internal_person.rb
264
+ - lib/eco/api/common/version_patches/ecoportal_api.rb
265
+ - lib/eco/api/common/version_patches/ecoportal_api/base_model.rb
266
+ - lib/eco/api/common/version_patches/ecoportal_api/external_person.rb
267
+ - lib/eco/api/common/version_patches/ecoportal_api/internal_person.rb
268
+ - lib/eco/api/common/version_patches/hash.rb
269
+ - lib/eco/api/common/version_patches/hash/deep_merge.rb
265
270
  - lib/eco/api/eco_faker.rb
271
+ - lib/eco/api/error.rb
272
+ - lib/eco/api/error/handler.rb
273
+ - lib/eco/api/error/handlers.rb
266
274
  - lib/eco/api/organization.rb
267
275
  - lib/eco/api/organization/people.rb
268
276
  - lib/eco/api/organization/person_schemas.rb
@@ -273,14 +281,14 @@ files:
273
281
  - lib/eco/api/organization/presets_values.json
274
282
  - lib/eco/api/organization/tag_tree.rb
275
283
  - lib/eco/api/policies.rb
276
- - lib/eco/api/policies/base_policy.rb
277
284
  - lib/eco/api/policies/policy.rb
278
- - lib/eco/api/policies/used_policies.rb
279
285
  - lib/eco/api/session.rb
280
286
  - lib/eco/api/session/batch.rb
281
- - lib/eco/api/session/batch_job.rb
282
- - lib/eco/api/session/batch_jobs.rb
283
- - lib/eco/api/session/batch_status.rb
287
+ - lib/eco/api/session/batch/errors.rb
288
+ - lib/eco/api/session/batch/job.rb
289
+ - lib/eco/api/session/batch/jobs.rb
290
+ - lib/eco/api/session/batch/jobs_groups.rb
291
+ - lib/eco/api/session/batch/status.rb
284
292
  - lib/eco/api/session/config.rb
285
293
  - lib/eco/api/session/config/api.rb
286
294
  - lib/eco/api/session/config/apis.rb
@@ -289,11 +297,14 @@ files:
289
297
  - lib/eco/api/session/config/logger.rb
290
298
  - lib/eco/api/session/config/mailer.rb
291
299
  - lib/eco/api/session/config/people.rb
300
+ - lib/eco/api/session/config/post_launch.rb
292
301
  - lib/eco/api/session/config/s3_storage.rb
293
- - lib/eco/api/session/job_groups.rb
302
+ - lib/eco/api/session/config/workflow.rb
294
303
  - lib/eco/api/session/task.rb
295
304
  - lib/eco/api/usecases.rb
296
305
  - lib/eco/api/usecases/base_case.rb
306
+ - lib/eco/api/usecases/base_io.rb
307
+ - lib/eco/api/usecases/default_case.rb
297
308
  - lib/eco/api/usecases/default_cases.rb
298
309
  - lib/eco/api/usecases/default_cases/change_email_case.rb
299
310
  - lib/eco/api/usecases/default_cases/create_case.rb
@@ -320,12 +331,21 @@ files:
320
331
  - lib/eco/api/usecases/use_case.rb
321
332
  - lib/eco/api/usecases/use_case_chain.rb
322
333
  - lib/eco/api/usecases/use_case_io.rb
323
- - lib/eco/api/usecases/use_group.rb
324
334
  - lib/eco/assets.rb
325
335
  - lib/eco/assets/language.rb
326
336
  - lib/eco/cli.rb
327
337
  - lib/eco/cli/config.rb
328
- - lib/eco/cli/config/options.rb
338
+ - lib/eco/cli/config/default.rb
339
+ - lib/eco/cli/config/default/filters.rb
340
+ - lib/eco/cli/config/default/input.rb
341
+ - lib/eco/cli/config/default/options.rb
342
+ - lib/eco/cli/config/default/people.rb
343
+ - lib/eco/cli/config/default/usecases.rb
344
+ - lib/eco/cli/config/default/workflow.rb
345
+ - lib/eco/cli/config/input.rb
346
+ - lib/eco/cli/config/options_set.rb
347
+ - lib/eco/cli/config/people_filters.rb
348
+ - lib/eco/cli/config/use_cases.rb
329
349
  - lib/eco/cli/scripting.rb
330
350
  - lib/eco/cli/scripting/args_helpers.rb
331
351
  - lib/eco/cli/scripting/argument.rb
@@ -1,14 +0,0 @@
1
- module Eco
2
- module API
3
- module Policies
4
- class BasePolicy < Eco::API::UseCases::BaseCase
5
-
6
- def initialize(policies, **options)
7
- raise "Expected UsedPolicies. Given: #{policies.class}" unless policies.is_a?(UsedPolicies)
8
- super(policies, **options)
9
- end
10
-
11
- end
12
- end
13
- end
14
- end
@@ -1,37 +0,0 @@
1
- module Eco
2
- module API
3
- module Policies
4
- class UsedPolicies < Eco::API::UseCases::UseGroup
5
-
6
- attr_reader :policies
7
-
8
- def add(policy)
9
- raise "Expected Policy object. Given: #{policy}" if !policy || !policy.is_a?(Policy)
10
- super(policy)
11
- end
12
-
13
- def define(name, type: :transform, &block)
14
- Policy.new(name, type: type, root: self, &block).tap do |policy|
15
- add(policy)
16
- end
17
- end
18
-
19
- # TODO: decide if policies deal with queue or single person
20
- def launch(people:, session:, options: {})
21
-
22
- args = {
23
- people: people,
24
- session: session,
25
- options: options
26
- }
27
-
28
- items.map do |policy|
29
- session.logger.debug("UsedPolicies: going to process '#{policy.name}' policy")
30
- policy.launch(**args)
31
- end
32
- end
33
- end
34
-
35
- end
36
- end
37
- end
@@ -1,215 +0,0 @@
1
- module Eco
2
- module API
3
- class Session
4
- class BatchJob < API::Common::Session::BaseSession
5
- TYPES = [:get, :create, :update, :delete]
6
- SETS = [:core, :details, :account]
7
-
8
- class << self
9
- def valid_type?(value)
10
- TYPES.include?(value)
11
- end
12
-
13
- def valid_sets?(value)
14
- sets = [value].flatten
15
- sets.all? { |s| SETS.include?(s) }
16
- end
17
- end
18
-
19
- attr_reader :name, :status
20
- attr_reader :usecase
21
-
22
- def initialize(e, name:, type:, sets:, usecase: nil)
23
- raise "A name is required to refer a job. Given: #{name}" if !name
24
- raise "Type should be one of #{TYPES}. Given: #{type}" if !self.class.valid_type?(type)
25
- raise "Sets should be some of #{SETS}. Given: #{sets}" if !self.class.valid_sets?(sets)
26
- raise "usecase must be a Eco::API::UseCases::UseCase object. Given: #{usecase.class}" if usecase && !usecase.is_a?(Eco::API::UseCases::UseCase)
27
- super(e)
28
-
29
- @name = name
30
- @type = type
31
- @usecase = usecase
32
- @sets = [sets].flatten.compact
33
- reset
34
- end
35
-
36
- def reset
37
- @queue = []
38
- @queue_hash = {}
39
- @callbacks = {}
40
- @status = nil
41
- end
42
-
43
- def usecase?
44
- !!usecase
45
- end
46
-
47
- def signature
48
- "job \"#{name}\" ['#{@type.to_s.upcase}': #{sets_title}]"
49
- end
50
-
51
- def match?(type:, sets:)
52
- sets = [sets].flatten
53
- type == @type && (sets.order == @sets.order)
54
- end
55
-
56
- def pending?
57
- !@status
58
- end
59
-
60
- def core?
61
- sets.include?(:core)
62
- end
63
-
64
- def details?
65
- sets.include?(:details)
66
- end
67
-
68
- def account?
69
- sets.include?(:account)
70
- end
71
-
72
- # Adds an entry to the job queue.
73
- # @param entry [Person] the person we want to update, carrying the changes to be done.
74
- # @param unique [Boolean] specifies if repeated entries should be avoided in the queue.
75
- # @yield [person] callback before launching the batch job request against the server.
76
- # @yeldparam param [Person] current person object that that should be treated by the callback before launching the batch.
77
- # @return [Void]
78
- def add(entry, unique: true)
79
- unless !entry
80
- unless unique && @queue_hash.key?(entry)
81
- @queue_hash[entry] = true
82
- @queue.push(entry)
83
- @callbacks[entry] = Proc.new if block_given?
84
- end
85
- end
86
- end
87
-
88
- def people(input = @queue)
89
- Eco::API::Organization::People.new(input)
90
- end
91
-
92
- def processed_queue
93
- pre_queue = @queue.map do |e|
94
- if callback = @callbacks[e]
95
- callback.call(e)
96
- end
97
- e = nil if as_update(e).empty?
98
- e
99
- end.compact
100
- apply_policies(pre_queue)
101
- end
102
-
103
- def processed_queue
104
- @queue.each {|e| @callbacks[e].call(e) if @callbacks.key?(e) }
105
- apply_policies(@queue).select {|e| !as_update(e).empty?}
106
- end
107
-
108
- def launch(simulate: false)
109
- queue = processed_queue
110
- launch_feedback(queue, simulate ? 2500 : 800)
111
-
112
- if !simulate
113
- if queue.length > 0
114
- backup_update(queue)
115
- @status = session.batch.launch(queue, method: @type)
116
- @status.root = self
117
- end
118
- end
119
-
120
- post_launch(queue: queue, simulate: simulate)
121
-
122
- logger.info("Simulate: this would have launched: '#{@type}'") if simulate
123
- return @status
124
- end
125
-
126
-
127
- private
128
-
129
- def post_launch(queue: [], simulate: false)
130
- if !simulate && @status
131
- @status.queue.map do |entry|
132
- if @status.success?(entry)
133
- entry.consolidate! if entry.respond_to?(:consolidate!)
134
- #else # shouldn't probably reset, as the model should remain dirty? (well tracaked)
135
- # entry.reset! if entry.respond_to?(:reset!)
136
- end
137
- end
138
- elsif simulate
139
- queue.map do |entry|
140
- entry.consolidate! if entry.respond_to?(:consolidate!)
141
- end
142
- end
143
- end
144
-
145
- def apply_policies(pre_queue)
146
- pre_queue.tap do |entries|
147
- policies = session.config.policies
148
- unless policies.empty?
149
- options = usecase?? usecase.options : {}
150
- policies.launch(people: people(entries), session: session, options: options)
151
- end
152
- end
153
- end
154
-
155
- def as_update(entry)
156
- hash = entry if entry.is_a?(Hash)
157
- if only_ids?
158
- hash = entry.as_json.slice("id", "external_id", "email")
159
- else
160
- if entry.is_a?(Ecoportal::API::V1::Person)
161
- hash = entry.as_update
162
- if hfields = hash.dig("details", "fields")
163
- hash["details"]["fields"] = hfields.map do |fld|
164
- fld.merge!("alt_id" => entry.details.get_field(fld["id"]).alt_id) if entry.details
165
- end
166
- end
167
- end
168
-
169
- fields = hash&.dig('details', 'fields')
170
- fields&.map! { |fld| fld&.slice("id", "alt_id", "value") }
171
- end
172
- hash || {}
173
- end
174
-
175
- def only_ids?
176
- [:delete, :get].include?(@type)
177
- end
178
-
179
- def sets_title
180
- "#{@sets.map {|s| s.to_s}.join(", ")}"
181
- end
182
-
183
- def launch_feedback(data, max_chars = 800)
184
- if !data || !data.is_a?(Enumerable) || data.empty?
185
- logger.warn("#{"*" * 20} Nothing for #{signature} so far :) #{"*" * 20}")
186
- return
187
- end
188
- header = ("*" * 20) + " #{signature} - Feedback Sample " + ("*" * 20)
189
- logger.info(header)
190
-
191
- sample_length = 1
192
- sample = data.slice(0, 20).map do |entry|
193
- update = as_update(entry)
194
- max_chars -= update.pretty_inspect.length
195
- sample_length += 1 if max_chars > 0
196
- update
197
- end
198
-
199
- logger.info("#{sample.slice(0, sample_length).pretty_inspect}")
200
- logger.info("#{@type.to_s.upcase} length: #{data.length}")
201
- logger.info("*" * header.length)
202
- end
203
-
204
- def backup_update(data)
205
- data_body = data.map { |u| as_update(u) }
206
- dir = config.people.requests_folder
207
- file = File.join(dir, "#{@type}_data.json")
208
- file_manager.save_json(data_body, file, :timestamp)
209
- end
210
-
211
- end
212
-
213
- end
214
- end
215
- end