eco-helpers 2.0.22 → 2.0.23

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ba43099c7902b3e2623640a196abd86f39215403d28e7a614da78b2422629323
4
- data.tar.gz: 7e3701cbeb7b3a0a65453dc002d6f4c5cb6e6ec4103e6cd0178c1af333d29d7d
3
+ metadata.gz: 2fb1adac01fbf3e34dfc80ca54c8254f660fc12deb3be3b20b395e3fc84fb8a7
4
+ data.tar.gz: b6d8d61a28333eb7446654589e32725b22c875741df08f9a2401315b6ef6b1b5
5
5
  SHA512:
6
- metadata.gz: f14ab296c2cff2dc694ef9182593329ca1bc86cf08ca32ba879cd5e74d658d1d123add425bc62a981182b9e4da06b33d225d613cd1a9d9cbfd7284e6b6d24ea5
7
- data.tar.gz: f020822ad4ae2e18f1f0424bb3a47417ff9a6bc78a439517cee3cd9212548efe4c89256579d73ccde27709dc5d2ea3d3e74bd072de23d4c089ccf3c7a107fc07
6
+ metadata.gz: c45a670a64f0e2a725542aa47776800b1a013dbc222a676b1ed813c5cb6aad425b8e0d0b906a06a8fce37fc89de2b329998a0c5ec9861bf2b3de42d10b560b47
7
+ data.tar.gz: df2f0fc1e776bbdc8dbf8de622944444b84b8b1cf9446002299fbd60d4f062b73e42d1828403996be0f42251d21db27c6bdb227a1d3b9dd979cde4799148915e
data/CHANGELOG.md CHANGED
@@ -1,6 +1,17 @@
1
1
  # Change Log
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
+ ## [2.0.23] - 2021-06-xx
5
+
6
+ ### Added
7
+ - `Eco::API::Session::Batch::Job` **new** option (`-save-requests`) to save requests even if in `dry-run` (`-simulate`)
8
+ ### Changed
9
+ - `Eco::API::Session::Batch::Job` new people won't create updates unless they have either details or account
10
+ * because that entry is not supposed to be created unless has account or details
11
+
12
+ ### Fixed
13
+
14
+
4
15
  ## [2.0.22] - 2021-06-18
5
16
 
6
17
  ### Added
@@ -25,8 +36,6 @@ All notable changes to this project will be documented in this file.
25
36
  - custom `Error` classes now all inherit from `StandardError` (rather than `Exception`)
26
37
 
27
38
 
28
- ### Fixed
29
-
30
39
 
31
40
  ## [2.0.21] - 2021-06-04
32
41
 
@@ -164,12 +164,17 @@ module Eco
164
164
  # @return [Eco::API::Session::Batch::Status]
165
165
  def launch(simulate: false)
166
166
  pqueue = processed_queue
167
- @requests = pqueue.map {|e| as_update(e)}
167
+ @requests = as_update(pqueue)
168
168
  pre_checks(requests, simulate: simulate)
169
169
 
170
- unless simulate
170
+ if simulate
171
+ if options.dig(:requests, :backup)
172
+ req_backup = as_update(pqueue, add_feedback: false)
173
+ backup_update(req_backup, simulate: simulate)
174
+ end
175
+ else
171
176
  if pqueue.length > 0
172
- req_backup = pqueue.map {|e| as_update(e, add_feedback: false)}
177
+ req_backup = as_update(pqueue, add_feedback: false)
173
178
  backup_update(req_backup)
174
179
  session.batch.launch(pqueue, method: type).tap do |job_status|
175
180
  @status = job_status
@@ -220,13 +225,26 @@ module Eco
220
225
  end.join("\n")
221
226
  end
222
227
 
223
- def as_update(*args)
224
- feedback.as_update(*args)
228
+ def as_update(data, *args)
229
+ if data.is_a?(Array)
230
+ data.map do |e|
231
+ feedback.as_update(e, *args)
232
+ end.compact.select {|e| e && !e.empty?}
233
+ else
234
+ feedback.as_update(data, *args)
235
+ end
225
236
  end
226
237
 
227
238
  def processed_queue
228
239
  @queue.each {|e| @callbacks[e].call(e) if @callbacks.key?(e) }
229
- apply_policies(api_included(@queue)).select {|e| !as_update(e).empty?}
240
+ apply_policies(api_included(@queue)).select do |e|
241
+ !as_update(e).empty?
242
+ end.select do |e|
243
+ next true unless e.is_a?(Ecoportal::API::V1::Person)
244
+ next true unless e.new?
245
+ # new people should either have account or details
246
+ e.account || e.details
247
+ end
230
248
  end
231
249
 
232
250
  # if there is a config definition to exclude entries
@@ -307,9 +325,10 @@ module Eco
307
325
  end
308
326
 
309
327
  # Keep a copy of the requests for future reference
310
- def backup_update(requests)
328
+ def backup_update(requests, simulate: false)
329
+ dry_run = simulate ? "_dry_run" : ""
311
330
  dir = config.people.requests_folder
312
- file = File.join(dir, "#{type}_data.json")
331
+ file = File.join(dir, "#{type}_data#{dry_run}.json")
313
332
  file_manager.save_json(requests, file, :timestamp)
314
333
  end
315
334
 
@@ -66,6 +66,11 @@ ASSETS.cli.config do |cnf|
66
66
  })
67
67
  end
68
68
 
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
+
69
74
  desc = "Used to specify the cache file of people to be used. "
70
75
  desc += "It is useful to use as people reference those stored in cached file diffrent to the last one."
71
76
  options_set.add("-people-from-backup", desc) do |options, session|
data/lib/eco/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Eco
2
- VERSION = "2.0.22"
2
+ VERSION = "2.0.23"
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: 2.0.22
4
+ version: 2.0.23
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oscar Segura