eco-helpers 2.0.10 → 2.0.11

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: b8ca1a088cf60b7608e9f92da680a631c73228ae92fed33484b5669c480350fb
4
- data.tar.gz: 6733d55fbdcf24c2766529c275f86f3132f1c3232b4c8d31f34880f9253dbc82
3
+ metadata.gz: 61ef9270db24cf1582814423b75bc1f3a74bf88cd14281862658c972d1f94f05
4
+ data.tar.gz: 30ac39b330426fcb8840b7e7456d240e6e7324030aea00b6950328708bbeb53b
5
5
  SHA512:
6
- metadata.gz: d1cdc2aacd52c590230fe606b079d91e6f3dea01ddbd8857d48170467bbfd089ffa7081c8630aac93ebae4c6e3b8125a446cd7ddc8a6b290c174e906661b2474
7
- data.tar.gz: 356ccf7e50d3f0e12f9ad1dde6f1fe7ad4fd13205334f9319cecd45736f110684eb404113512aca4b1d2c49070fe61eb48b1e69c3ae13f423ae8895288ea0d2d
6
+ metadata.gz: 4dcfa4714c6b245c017194eb6b3fb623702472c260f5717b5485141fb9765fd7e10f891938e65978b7bc13142cc45e06efbc430db9cb63270355f6341e0991d3
7
+ data.tar.gz: 7cd4382209bef6d5b0db07b2adb90237500050b4ac9340ec39457f7f23d1131bc6562367bc5cf005fdcc4f3af1553dafd446aa02e551549b1bbb90c08e51e15d
data/CHANGELOG.md CHANGED
@@ -1,7 +1,16 @@
1
1
  # Change Log
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
- ## [2.0.10] - 2021-03-xx
4
+ ## [2.0.11] - 2021-03-xx
5
+
6
+ ### Added
7
+
8
+ ### Changed
9
+
10
+ ### Fixed
11
+ - `Eco::API::Session::Batch:Errors#errors` changed `Array#filter` call to `Array#select` call
12
+
13
+ ## [2.0.10] - 2021-03-26
5
14
 
6
15
  ### Added
7
16
  - `Eco::API::Common::People::PersonParser`
@@ -124,7 +124,7 @@ module Eco
124
124
  # - please, observe that this can only happen if there were repeated entries in the `source_queue`
125
125
  # @return [Array<Hash>, Array<Ecoportal::API::V1::Person>, Array<Ecoportal::API::Internal::Person>]
126
126
  def entries
127
- queue.filter.with_index do |query, i|
127
+ queue.select.with_index do |query, i|
128
128
  unless response = status[i]
129
129
  msg = "Error: query with no response. You might have duplicated entries in your queue.\n"
130
130
  msg += "Queue length: #{queue.length}; Queue elements class: #{queue.first.class}\n"
@@ -45,25 +45,22 @@ module Eco
45
45
  # @!group Pure feedback methods
46
46
 
47
47
  # Slightly modifies the behaviour of `Ecoportal::API::Common::BaseModel#as_update`, so schema details fields show the `alt_id`
48
+ # It also fixes possible patch updates that are incomplete or unnecessary.
48
49
  # @note for better feedback
49
50
  # @param entry [Hash, Ecoportal::API::V1::Person, Ecoportal::API::Internal::Person]
50
- def as_update(entry)
51
+ # @param add_feedback [Boolean] if `true` it tweak the hash update with additional data.
52
+ def as_update(entry, add_feedback: true)
51
53
  case
52
54
  when entry.is_a?(Hash)
53
55
  hash = entry
54
56
  else #entry.is_a?(Ecoportal::API::V1::Person)
55
57
  if only_ids?
56
- hash = {
57
- "id" => entry.id,
58
- "external_id" => entry.external_id,
59
- "email" => entry.email
60
- }
61
58
  hash = entry.as_json.slice("id", "external_id", "email")
62
59
  else
63
60
  hash = entry.as_update
64
- #if entry.details
65
- if hash["details"]
66
- if hfields = hash.dig("details", "fields")
61
+
62
+ if add_feedback && details = hash["details"]
63
+ if hfields = details["fields"]
67
64
  hfields.each do |fld|
68
65
  fld.merge!("alt_id" => entry.details.get_field(fld["id"]).alt_id)
69
66
  end
@@ -169,7 +169,8 @@ module Eco
169
169
 
170
170
  unless simulate
171
171
  if pqueue.length > 0
172
- backup_update(requests)
172
+ req_backup = pqueue.map {|e| as_update(e, add_feedback: false)}
173
+ backup_update(req_backup)
173
174
  session.batch.launch(pqueue, method: type).tap do |job_status|
174
175
  @status = job_status
175
176
  status.root = self
@@ -217,7 +218,7 @@ module Eco
217
218
  [].tap do |msg|
218
219
  subjobs.map {|subjob| msg << subjob.summary}
219
220
  end.join("\n")
220
- end
221
+ end
221
222
 
222
223
  def as_update(*args)
223
224
  feedback.as_update(*args)
data/lib/eco/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Eco
2
- VERSION = "2.0.10"
2
+ VERSION = "2.0.11"
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.10
4
+ version: 2.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oscar Segura