eco-helpers 2.0.45 → 2.0.46

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: f85bd156250d1f44ca911d98007005cbbb2281ff4a40a2fc07a80680fd42a408
4
- data.tar.gz: 4ccda90fbf7d1bbfc814d18cd033110b7af2ae366687af1fa2db10370788c52d
3
+ metadata.gz: fd9b2a6564e5ce38fa3ed762ab04f5e4e79b1a6580738d9091b846233c6fb66e
4
+ data.tar.gz: ac0200ad60b30fc0d40997b4975f016daee8cd48c881bfecae106ca0867ff123
5
5
  SHA512:
6
- metadata.gz: f4b7add6e04fb8b4dfa0c56371bc3f85e791659754e937f60586b88dec06186723f9286c87482144bd9b012298dbc03251388c49f1245008026a186cd6d16a88
7
- data.tar.gz: 7a0bfda7154a8c0e7bb7e18100a96cd2a45f26a6d45309725e7d796dd9d0ad48cefb35be551c031706757d1241fab7505d74f401cf6a04764547bbe8c582e076
6
+ metadata.gz: f72270169fd60eaee60b27d333391bc6d2235fe856752d9f7dcd5d5aca18fd129e148cd0830bea37cd86833cabc64f10e4fb09e71c4ba2ba9b6912313da82b4a
7
+ data.tar.gz: 690b338d062020a6d80794d794f00f8ce9c263bb8b12a84f774f50193bd49ff474b6a49f670a1e05df9a2db88f70d3639c54582fc8706617c44123753c0a7b9e
data/CHANGELOG.md CHANGED
@@ -1,17 +1,40 @@
1
1
  # Change Log
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
- ## [2.0.45] - 2021-11-xx
4
+ ## [2.0.46] - 2021-12-24
5
+
6
+ ### Added
7
+ - `Eco::API::UseCases::OozeSamples::RegisterUpdateCase`
8
+ - added counter of retrieved entries (to be able to compare with matched initially scoped results)
9
+ - added also counter of failed to retrieve oozes
10
+ - added also counter of double ups in search pagination
11
+ - counter for updated pages and pages that failed update
12
+ - `Eco::API::Session#enviro_name`: to identify in whic environment we are running
13
+
14
+ ### Changed
15
+ - upgraded `ecoportal-api-v2` dependency
16
+ - `Eco::API::UseCases::OozeSamples::OozeBaseCase#update_ooze`
17
+ - To return `false` if there was request made to the server
18
+ - To return `Reponse` if there was request made to the server
19
+
20
+ ### Fixed
21
+ - Changed the `workflow` in
22
+ - `on(:end)` to do not recache people if there were no `:sync` or `:transform` cases
23
+ - `Eco::API::UseCases::OozeSamples::OozeRunBaseCase#update_ooze`
24
+ - It's parent had parameter (it as a child should so)
25
+ - `Eco::API::UseCases::OozeSamples::OozeBaseCase#process_ooze`
26
+ - It was not retrieving the `ooze` unless explicitly passed as parameter
27
+ - This did not play well with child implementations that expect it to retrieve it based on `ooze_id` cli argument
28
+
29
+ ## [2.0.45] - 2021-12-15
5
30
 
6
31
  ### Added
7
32
  - `Eco::API::UseCases::OozeSamples::RegisterExportCase`
8
-
33
+
9
34
  ### Changed
10
35
  - Upgrade `ecoportal-api` dependency
11
36
  - Upgrade `ecoportal-api-v2` dependency
12
37
 
13
- ### Fixed
14
-
15
38
  ## [2.0.44] - 2021-11-25
16
39
 
17
40
  ### Changed
data/eco-helpers.gemspec CHANGED
@@ -31,7 +31,7 @@ Gem::Specification.new do |spec|
31
31
  spec.add_development_dependency "redcarpet", ">= 3.5.1", "< 3.6"
32
32
 
33
33
  spec.add_dependency 'ecoportal-api', '>= 0.8.4', '< 0.9'
34
- spec.add_dependency 'ecoportal-api-v2', '>= 0.8.21', '< 0.9'
34
+ spec.add_dependency 'ecoportal-api-v2', '>= 0.8.23', '< 0.9'
35
35
  spec.add_dependency 'aws-sdk-s3', '>= 1.83.0', '< 2'
36
36
  spec.add_dependency 'aws-sdk-ses', '>= 1.36.0', '< 2'
37
37
  spec.add_dependency 'dotenv', '>= 2.7.6', '< 2.8'
@@ -30,7 +30,7 @@ module Eco
30
30
  people_load(modifier: modifier - [:newest, :file])
31
31
  end
32
32
  when modifier.include?(:api)
33
- logger.info("Going to get all the people via API")
33
+ logger.info("Going to get all the people via API (load)")
34
34
 
35
35
  start = Time.now
36
36
  session.batch.get_people.tap do |people|
@@ -17,6 +17,11 @@ module Eco
17
17
  logger.debug("LINE COMMAND: #{$0} #{ARGV.join(" ")}")
18
18
  end
19
19
 
20
+ # @retrun [String] the name of the current environment
21
+ def enviro_name
22
+ config.active_enviro
23
+ end
24
+
20
25
  # @return [Eco::API::Session::Batch] provides helper to launch batch operations.
21
26
  def batch
22
27
  @batch ||= Batch.new(enviro)
@@ -20,10 +20,11 @@ class Eco::API::UseCases::OozeSamples::OozeBaseCase < Eco::API::Common::Loaders:
20
20
  end
21
21
 
22
22
  # Write here your script
23
- def process_ooze(ooze = target)
23
+ def process_ooze(ooz = target)
24
+ ooz ||= ooze
24
25
  raise "You need to inherit from this class ('#{self.class}') and call super with a block" unless block_given?
25
- yield(ooze)
26
- update_ooze(ooze)
26
+ yield(ooz)
27
+ update_ooze(ooz)
27
28
  end
28
29
 
29
30
  protected
@@ -109,10 +110,12 @@ class Eco::API::UseCases::OozeSamples::OozeBaseCase < Eco::API::Common::Loaders:
109
110
  exit_error "Stage '#{id_name}' doesn't exist in ooze '#{ooze_id}'"
110
111
  end
111
112
 
113
+ # It fill update the ooze only if it's dirty (it carries changes)
114
+ # @return [Boolean, Response] `false` if there was not request against the server, `Response` otherwise
112
115
  def update_ooze(ooze = target)
113
116
  if !options[:simulate]
114
- return unless dirty?(ooze)
115
-
117
+ return false unless dirty?(ooze)
118
+
116
119
  ooze.validate.tap do |validation|
117
120
  raise validation if validation.is_a?(String)
118
121
  end
@@ -133,6 +136,7 @@ class Eco::API::UseCases::OozeSamples::OozeBaseCase < Eco::API::Common::Loaders:
133
136
  end
134
137
  backup_patch!(ooze)
135
138
  exit(0) if dirty?(ooze) && dry_count > DRY_COUNT
139
+ false
136
140
  end
137
141
  end
138
142
 
@@ -39,9 +39,9 @@ class Eco::API::UseCases::OozeSamples::OozeRunBaseCase < Eco::API::UseCases::Ooz
39
39
  options.dig(:source, :stage_id)
40
40
  end
41
41
 
42
- def update_ooze
42
+ def update_ooze(ooz = target)
43
43
  prompt_to_confirm!
44
- super
44
+ super(ooz)
45
45
  end
46
46
 
47
47
  def exit_if_no_changes!
@@ -17,12 +17,30 @@ class Eco::API::UseCases::OozeSamples::RegisterUpdateCase < Eco::API::UseCases::
17
17
  name "register-update-case"
18
18
  type :other
19
19
 
20
+ attr_reader :retrieved_oozes, :non_retrieved_oozes
21
+ attr_reader :total_search_oozes, :dupped_search_oozes
22
+ attr_reader :ooze_result_ids, :updated_oozes, :failed_update_oozes
23
+
20
24
  def main(session, options, usecase, &block)
25
+ @retrieved_oozes = 0
26
+ @non_retrieved_oozes = 0
27
+ @dupped_search_oozes = 0
28
+ @ooze_result_ids = {}
29
+ @updated_oozes = 0
30
+ @failed_update_oozes = 0
31
+
21
32
  super(session, options, usecase) do
22
33
  with_each_entry do |ooze|
23
34
  process_ooze(&block)
24
35
  end
25
36
  end
37
+ msg = "Run end:\n"
38
+ msg += " • Search results: #{total_search_oozes}\n"
39
+ msg += " • Duplicated search results #{dupped_search_oozes}\n"
40
+ msg += " • Retrieved a total of #{retrieved_oozes}\n"
41
+ msg += " • Could not get #{non_retrieved_oozes} oozes.\n"
42
+ msg += " • Updated #{updated_oozes} oozes (failed update on #{failed_update_oozes} oozes).\n"
43
+ logger.info(msg)
26
44
  end
27
45
 
28
46
  def process_ooze(ooze = target)
@@ -47,7 +65,14 @@ class Eco::API::UseCases::OozeSamples::RegisterUpdateCase < Eco::API::UseCases::
47
65
  def with_each_entry
48
66
  batched_search_results do |page_results|
49
67
  page_results.each do |page_result|
68
+ if ooze_result_ids[page_result.id]
69
+ @dupped_search_oozes += 1
70
+ else
71
+ ooze_result_ids[page_result.id] = true
72
+ end
73
+
50
74
  if pending = queue_shift(page_result.id)
75
+
51
76
  if dirty?(pending)
52
77
  msg = "Inconsistent search results. "
53
78
  msg << "Launching update on '#{object_reference(pending)}' to be able to queue it back"
@@ -56,7 +81,11 @@ class Eco::API::UseCases::OozeSamples::RegisterUpdateCase < Eco::API::UseCases::
56
81
  end
57
82
  end
58
83
  if ooz = ooze(page_result.id)
84
+ @retrieved_oozes += 1
59
85
  yield(ooz)
86
+ else
87
+ @non_retrieved_oozes += 1
88
+ console.warn "Could not get page #{page_result.id}"
60
89
  end
61
90
  end
62
91
  update_oozes
@@ -113,7 +142,15 @@ class Eco::API::UseCases::OozeSamples::RegisterUpdateCase < Eco::API::UseCases::
113
142
 
114
143
  def update_oozes(batched_oozes = batch_queue)
115
144
  batched_oozes.each do |ooze|
116
- update_ooze(ooze)
145
+ update_ooze(ooze).tap do |result|
146
+ if result.is_a?(Ecoportal::API::Common::Response)
147
+ if result.success?
148
+ @updated_oozes += 1
149
+ else
150
+ @failed_update_oozes +=1
151
+ end
152
+ end
153
+ end
117
154
  end
118
155
  batched_oozes.clear
119
156
  end
@@ -127,6 +164,7 @@ class Eco::API::UseCases::OozeSamples::RegisterUpdateCase < Eco::API::UseCases::
127
164
 
128
165
  def results_preview
129
166
  apiv2.registers.search(register_id, search_options.merge(only_first: true)).tap do |search_results|
167
+ @total_search_oozes = search_results.total
130
168
  str_results = "Total target entries: #{search_results.total} (out of #{search_results.total_before_filtering})"
131
169
  session.prompt_user("Do you want to proceed (y/N):", explanation: str_results, default: "N", timeout: 10) do |res|
132
170
  unless res.upcase.start_with?("Y")
@@ -3,6 +3,8 @@ ASSETS.cli.config do |config|
3
3
 
4
4
  io = nil
5
5
  rescued = false
6
+ cases_with_input = nil
7
+ cases_with_output = nil
6
8
 
7
9
  # default rescue
8
10
  wf.rescue do |exception, io|
@@ -165,9 +167,16 @@ ASSETS.cli.config do |config|
165
167
  wf.on(:end) do |wf_end, io|
166
168
  get_people = io.options.dig(:people, :get)
167
169
  partial_update = get_people && get_people.dig(:type) == :partial
170
+
168
171
  unless !io.options[:end_get] || io.options[:dry_run] || partial_update
169
- # Prevent getting people when there were no use cases that used them
170
- unless io.people
172
+ people_update_cases = config.usecases.active(io: io).any? do |usecase, data|
173
+ [:transform, :sync].any? {|type| usecase.type == type}
174
+ end
175
+
176
+ if !people_update_cases
177
+ # Prevent getting people when there were no use cases that used them
178
+ io.session.logger.info("Won't be recaching people, as there haven't been any targetted updates")
179
+ elsif !io.people
171
180
  people = io.session.micro.people_cache
172
181
  io = io.new(people: people)
173
182
  end
data/lib/eco/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Eco
2
- VERSION = "2.0.45"
2
+ VERSION = "2.0.46"
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.45
4
+ version: 2.0.46
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oscar Segura
@@ -136,7 +136,7 @@ dependencies:
136
136
  requirements:
137
137
  - - ">="
138
138
  - !ruby/object:Gem::Version
139
- version: 0.8.21
139
+ version: 0.8.23
140
140
  - - "<"
141
141
  - !ruby/object:Gem::Version
142
142
  version: '0.9'
@@ -146,7 +146,7 @@ dependencies:
146
146
  requirements:
147
147
  - - ">="
148
148
  - !ruby/object:Gem::Version
149
- version: 0.8.21
149
+ version: 0.8.23
150
150
  - - "<"
151
151
  - !ruby/object:Gem::Version
152
152
  version: '0.9'