eco-helpers 2.0.12 → 2.0.13

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: 3506fbbcb2da4707ebb9451ea0f4afe1549923a4af2aed306d929243a94016df
4
- data.tar.gz: 5279c8a96662b19c097cb9d2e0a35b2d29ccb917ec77873ff0fb248b83d51069
3
+ metadata.gz: 726f5a5930889b9fd59b4acc4ce7b938e3c6011909c2f5a5bb1a105a36df4d9b
4
+ data.tar.gz: 804bc3ae796491543ec3615e9f11308333e7ea6fc9a10f943778f66922aa4a25
5
5
  SHA512:
6
- metadata.gz: 5100d854ec4b3ca20f8127d4128325ad8e557d554167917af7d495761da81f2e21be2f45b33dd00b02d1d7f830299f1bcde6e88134db62b021ddef6c7a234f88
7
- data.tar.gz: d65ef75ed11d804ee4d45768533c8d4ccef60c88fc435dc6d9df909d87f962a7914036e110cf8c4231b53b1738c85369458ca2e464dc7efefce3e3760a9d4c04
6
+ metadata.gz: f2e1c852b4660ae1bdc3e94bab274f3d4b7168c6affef57315b370af102b71cff19cdb0c2de0b59899f82b7f2f8b0478688cf018f3c52f26c1f1d891ed19cd65
7
+ data.tar.gz: 032a93267eb45f7550fbdad7805d0f472a0ea1a98353b089147bd71de785cdeaa4933b233bdd22d4ab69f7a85bfa65ec1f0850fe82e446dcf4d5f503ba1f191b
data/CHANGELOG.md CHANGED
@@ -1,21 +1,24 @@
1
1
  # Change Log
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
- ## [2.0.12] - 2021-03-29
4
+ ## [2.0.13] - 2021-03-31
5
5
 
6
6
  ### Added
7
+ - Stats on the `Eco::API::Session::Batch`
8
+ - Allow to inherit and re-use the `Eco::API::UseCases::DefaultCase::HrisCase`
7
9
 
8
10
  ### Changed
9
- - `Eco::CLI#run` it does include any defined states on the workflow
10
11
 
11
12
  ### Fixed
13
+ - Ensure auto-loading for `Eco::API::UseCases`
12
14
 
15
+ ## [2.0.12] - 2021-03-29
13
16
 
14
- ## [2.0.11] - 2021-03-29
17
+ ### Changed
18
+ - `Eco::CLI#run` it does include any defined states on the workflow
15
19
 
16
- ### Added
17
20
 
18
- ### Changed
21
+ ## [2.0.11] - 2021-03-29
19
22
 
20
23
  ### Fixed
21
24
  - `Eco::API::Session::Batch:Errors#errors` changed `Array#filter` call to `Array#select` call
@@ -35,34 +38,24 @@ All notable changes to this project will be documented in this file.
35
38
  - Ranamed `#defined_attrs` to `#defined_model_attrs`
36
39
  - Ranamed `#undefined_attrs` to `#undefined_model_attrs`
37
40
 
38
- ### Fixed
39
-
40
41
  ## [2.0.9] - 2021-03-19
41
42
 
42
- ### Added
43
43
  ### Changed
44
44
  - `Eco::API::Session::Batch:Errors#person_ref` moved to the public method
45
45
 
46
- ### Fixed
47
-
48
46
  ## [2.0.8] - 2021-03-09
49
47
 
50
- ### Added
51
- ### Changed
52
48
  ### Fixed
53
49
  - `Ecoportal::API::V1::Person#identity` adjust behavior
54
50
 
55
51
  ## [2.0.7] - 2021-03-09
56
52
 
57
- ### Added
58
- ### Changed
59
53
  ### Fixed
60
54
  - `Eco::API::Session::Batch::JobsGroups` and `Eco::API::Session::Batch::Jobs`: when new `Batch::Job`s are creating during launch, they remained unlaunched
61
55
  - this fix makes `#launch` method to iterate until there are no pending
62
56
 
63
57
  ## [2.0.6] - 2021-03-08
64
58
 
65
- ### Added
66
59
  ### Changed
67
60
  - `Eco::API::Session::Batch:Errors` moved some methods to be private
68
61
  ### Fixed
@@ -70,46 +63,33 @@ All notable changes to this project will be documented in this file.
70
63
 
71
64
  ## [2.0.5] - 2021-02-24
72
65
 
73
- ### Added
74
- ### Changed
75
66
  ### Fixed
76
67
  - `Eco::API::Common::People::PersonParser#symbol_keys` to use `Array#select`
77
68
  - as `Array#filter` was introduced in ruby `2.5.5`
78
69
 
79
70
  ## [2.0.4] - 2021-02-23
80
71
 
81
- ### Added
82
72
  ### Changed
83
73
  - `Eco::API::Common::People::PersonParser#defined_attrs` to include virtual attributes
84
74
 
85
- ### Fixed
86
-
87
75
  ## [2.0.3] - 2021-02-23
88
76
 
89
77
  ### Added
90
78
  - `Eco::API::UseCases::OozeSamples::OozeUpdateCase`: added integration to update page instances (non-templates)
91
79
 
92
- ### Changed
93
80
  ### Fixed
94
81
  - `Eco::API::Policies::DefaultPolicies::UserAccess` complete default policy code.
95
82
 
96
83
  ## [2.0.2] - 2021-02-22
97
84
 
98
- ### Added
99
85
  ### Changed
100
86
  - upgraded dependencies with `ecoportal-api`
101
87
 
102
- ### Fixed
103
-
104
-
105
88
  ## [2.0.1] - 2021-02-22
106
89
 
107
- ### Added
108
90
  ### Changed
109
91
  - upgraded dependencies with `ecoportal-api-oozes` to `ecoportal-api-v2`
110
92
 
111
- ### Fixed
112
-
113
93
  ## [1.5.15] - 2021-02-17
114
94
 
115
95
  ### Added
@@ -123,7 +103,6 @@ All notable changes to this project will be documented in this file.
123
103
  - `Eco::API::MicroCases#people_search`
124
104
  - `Eco::API::MicroCases#refresh`
125
105
 
126
- ### Changed
127
106
  ### Fixed
128
107
  - `Eco::API::Policies::DefaultPolicies::UserAccess` typos in default api policy
129
108
 
@@ -145,11 +124,8 @@ All notable changes to this project will be documented in this file.
145
124
  - `Eco::API::Common::People::PersonEntry` add error log when wrong email error is detected
146
125
  - previously it would have crashed
147
126
 
148
- ### Fixed
149
-
150
127
  ## [1.5.13] - 2021-02-01
151
128
 
152
- ### Added
153
129
  ### Changed
154
130
  - upgraded dependency with `ecoportal-api-oozes`
155
131
 
@@ -165,23 +141,16 @@ All notable changes to this project will be documented in this file.
165
141
  ### Changed
166
142
  - upgraded `ecoportal-api` dependency
167
143
 
168
- ### Fixed
169
-
170
-
171
144
  ## [1.5.11] - 2021-01-25
172
145
 
173
146
  ### Added
174
147
  - `Eco::API::Organization::TagTree#subtag?` to check if the tag is in any subtree.
175
148
 
176
- ### Changed
177
-
178
149
  ### Fixed
179
150
  - `Eco::API::MicroCases#set_supervisor` shouldn't set it if the entry does not have it.
180
151
 
181
152
  ## [1.5.10] - 2021-01-19
182
153
 
183
- ### Added
184
- ### Changed
185
154
  ### Fixed
186
155
  - `Eco::API::Session::Batch::Errors#print` show the row number of the input data.
187
156
 
@@ -190,14 +159,8 @@ All notable changes to this project will be documented in this file.
190
159
  ### Added
191
160
  - `Eco::API::Organization::TagTree#subtags` to get all the tags but those of the highest level.
192
161
 
193
- ### Changed
194
- ### Fixed
195
-
196
-
197
162
  ## [1.5.8] - 2021-01-05
198
163
 
199
- ### Added
200
- ### Changed
201
164
  ### Fixed
202
165
  - `Eco::API::Session::Batch::Jobs#job` shouldn't be calling the post-launch callback function on creation.
203
166
  - `Eco::API::Session#new_job` should include a `&block` parameter.
@@ -205,15 +168,11 @@ All notable changes to this project will be documented in this file.
205
168
 
206
169
  ## [1.5.7] - 2020-12-17
207
170
 
208
- ### Added
209
- ### Changed
210
171
  ### Fixed
211
172
  - `Eco::API::Sesssion#parse_attribute` was not using phase argument
212
173
 
213
174
  ## [1.5.6] - 2020-12-04
214
175
 
215
- ### Added
216
- ### Changed
217
176
  ### Fixed
218
177
  - `Eco::API::UseCases::DefaultCases::RestoreDBCase` fixed typo and slightly improved
219
178
  - fixed some back-end errors when chaining usecases
@@ -221,8 +180,6 @@ All notable changes to this project will be documented in this file.
221
180
 
222
181
  ## [1.5.5] - 2020-12-03
223
182
 
224
- ### Added
225
- ### Changed
226
183
  ### Fixed
227
184
  - rubies previous to `2.5` do not have `yield_self`
228
185
 
@@ -230,14 +187,11 @@ All notable changes to this project will be documented in this file.
230
187
 
231
188
  ### Added
232
189
  - update `ecoportal-api` dependency
233
- ### Changed
234
190
  ### Fixed
235
191
  - `Eco::API::MicroCases#people_refresh` typo
236
192
 
237
193
  ## [1.5.3] - 2020-11-30
238
194
 
239
- ### Added
240
- ### Changed
241
195
  ### Fixed
242
196
  - `Eco::API::Session::Batch::RequestStats#blanked_value?` better blank detection
243
197
  - `Eco::API::MicroCases#with_each_starter` rectified typo
@@ -378,14 +332,11 @@ All notable changes to this project will be documented in this file.
378
332
 
379
333
  ## [1.4.2] - 2020-07-23
380
334
 
381
- ### Added
382
- ### Changed
383
335
  ### Fixed
384
336
  - preserve backtrace on logging
385
337
 
386
338
  ## [1.4.0] - 2020-07-14
387
339
 
388
- ### Added
389
340
  ### Changed
390
341
  - change abilities to align with ecoPortal release `1.5.0`
391
342
  - remove some patches on `ecoportal-api`
@@ -395,22 +346,17 @@ All notable changes to this project will be documented in this file.
395
346
 
396
347
  ## [1.3.19] - 2020-07-23
397
348
 
398
- ### Added
399
- ### Changed
400
349
  ### Fixed
401
350
  - preserve backtrace on logging
402
351
 
403
352
  ## [1.3.18] - 2020-07-08
404
353
 
405
- ### Added
406
- ### Changed
407
354
  ### Fixed
408
355
  - the `update` case was missing the code to use the `default_usergroup`
409
356
 
410
357
 
411
358
  ## [1.3.17] - 2020-07-06
412
359
 
413
- ### Added
414
360
  ### Changed
415
361
  - the `hris` case should not only include as `leavers` those that have account, but anyone that leaves
416
362
  * as we could have active people with no account
@@ -433,7 +379,6 @@ All notable changes to this project will be documented in this file.
433
379
  ### Added
434
380
  - default usecase to export to `csv` (`-detailed`) now includes `"Supervisor Name"` column
435
381
  ### Changed
436
- ### Fixed
437
382
 
438
383
  ## [1.3.14] - 2020-06-10
439
384
 
@@ -441,33 +386,24 @@ All notable changes to this project will be documented in this file.
441
386
  - `Eco::API::Common::People::SupervisorHelpers` now has its methods as class methods
442
387
  ### Changed
443
388
  - upgraded `ecoportal-api` gem dependency to minimum version `0.5.6`
444
- ### Fixed
445
389
 
446
390
 
447
391
  ## [1.3.13] - 2020-05-29
448
392
 
449
- ### Added
450
- ### Changed
451
393
  ### Fixed
452
394
  - `Eco::API::Organization::TagTree#tag?` to accept `nil` by returning `false`
453
395
  - `Eco::API::Common::People::DefaultParsers::DateParser` will parse to `Date` class
454
396
  * it was parsing to `Time` class, while the native gem `ecoportal-api` parses as `Date` ([reference](https://gitlab.com/ecoPortal/ecoportal-api/-/blob/master/lib/ecoportal/api/v1/schema_field.rb))
455
397
  ## [1.3.12] - 2020-05-19
456
398
 
457
- ### Added
458
399
  ### Changed
459
400
  - stop using `email` as `external_id` on `People#person` & `People#find`
460
401
  * this should result in more accurate searches when using `:strict` options
461
- ### Fixed
462
-
463
402
 
464
403
  ## [1.3.11] - 2020-05-12
465
404
 
466
- ### Added
467
405
  ### Changed
468
406
  - remove popping up comments on `Eco::API::Organization::PolicyGroups#`
469
- ### Fixed
470
-
471
407
 
472
408
  ## [1.3.10] - 2020-05-12
473
409
 
@@ -476,14 +412,11 @@ All notable changes to this project will be documented in this file.
476
412
  - `config.people.default_usergroup`, when defined, will have effect on usecases: `update` (this case was missing the change)
477
413
  * on account creation, if the input file did not specify `policy_group_ids`
478
414
 
479
- ### Changed
480
415
  ### Fixed
481
416
  - `upsert`, `hris` and `create` usecases: fixed condition for use of default_usergroup
482
417
 
483
418
  ## [1.3.9] - 2020-05-12
484
419
 
485
- ### Added
486
- ### Changed
487
420
  ### Fixed
488
421
 
489
422
  - `usecase` callback was not receiving `usecase` paramater
@@ -8,7 +8,7 @@ module Eco
8
8
  # @return [Symbol] the `type` of usecase (i.e. `:sync`, `:transform`, `:import`, `:other`)
9
9
  def type(value = nil)
10
10
  unless value
11
- return @type || raise("You should specify a type of case [:sync, :transform, :import, :other] for #{self.class}")
11
+ return @type || raise("You should specify a type of case [:sync, :transform, :import, :other] for #{self}")
12
12
  end
13
13
  @type = value
14
14
  end
@@ -105,10 +105,15 @@ module Eco
105
105
  iterations = (data.length.to_f / per_page).ceil
106
106
 
107
107
  Eco::API::Session::Batch::Status.new(enviro, queue: data, method: method).tap do |status|
108
+ start_time = Time.now
109
+ start_slice = Time.now; slice = []
108
110
  data.each_slice(per_page) do |slice|
109
- msg = "starting batch '#{method}' iteration #{iteration}/#{iterations}, with #{slice.length} entries of #{data.length} -- #{done} done"
111
+ msg = "starting batch '#{method}' iteration #{iteration}/#{iterations},"
112
+ msg += " with #{slice.length} entries of #{data.length} -- #{done} done"
113
+ msg += " (last: #{str_stats(start_slice, slice.length)}; total: #{str_stats(start_time, done)})"
110
114
  logger.info(msg) unless silent
111
115
 
116
+ start_slice = Time.now
112
117
  people_api.batch do |batch|
113
118
  slice.each do |person|
114
119
  batch.public_send(method, person) do |response|
@@ -118,12 +123,23 @@ module Eco
118
123
  end
119
124
  end # next batch
120
125
 
121
- iteration += 1
122
- done += slice.length
126
+ iteration += 1
127
+ done += slice.length
123
128
  end # next slice
124
129
  end
125
130
  end
126
131
 
132
+ def str_stats(start, count)
133
+ now = Time.now
134
+ secs = (now - start).round(3)
135
+ if secs > 0.0
136
+ per_sec = (count.to_f / secs).round(2)
137
+ "#{secs}s -> #{per_sec} people/s"
138
+ else
139
+ " -- "
140
+ end
141
+ end
142
+
127
143
  end
128
144
  end
129
145
  end
@@ -30,6 +30,7 @@ module Eco
30
30
  @usecases = {}
31
31
  @cache_init = false
32
32
  @cases_by_name = {}
33
+ init_caches
33
34
  end
34
35
 
35
36
  def length
@@ -79,6 +80,7 @@ module Eco
79
80
 
80
81
  # @return [Eco::API::UseCases] a copy of instance object of `self`.
81
82
  def dup
83
+ init_caches
82
84
  self.class.new.merge(self)
83
85
  end
84
86
 
@@ -2,18 +2,17 @@ class Eco::API::UseCases::DefaultCases::HrisCase < Eco::API::Common::Loaders::Us
2
2
  name "hris"
3
3
  type :sync
4
4
 
5
+ attr_reader :creation, :update, :supers, :leavers
6
+
5
7
  def main(entries, people, session, options, usecase)
6
8
  micro = session.micro
7
- creation = session.new_job("main", "create", :create, usecase)
8
- update = session.new_job("main", "update", :update, usecase)
9
- supers = session.new_job("post", "supers", :update, usecase, :core)
10
- leavers = session.new_job("post", "leavers", :update, usecase, :account)
9
+ @creation = session.new_job("main", "create", :create, usecase)
10
+ @update = session.new_job("main", "update", :update, usecase)
11
+ @supers = session.new_job("post", "supers", :update, usecase, :core)
12
+ @leavers = session.new_job("post", "leavers", :update, usecase, :account)
11
13
 
12
14
  micro.with_each_leaver(entries, people, options) do |person|
13
- leavers.add(person) do |person|
14
- person.supervisor_id = nil
15
- person.account = nil if person.account
16
- end
15
+ leavers.add(person, &method(:leavers_callback))
17
16
  end
18
17
 
19
18
  micro.with_each(entries, people, options) do |entry, person|
@@ -24,4 +23,11 @@ class Eco::API::UseCases::DefaultCases::HrisCase < Eco::API::Common::Loaders::Us
24
23
  end
25
24
  end
26
25
 
26
+ private
27
+
28
+ def leavers_callback(person)
29
+ person.supervisor_id = nil
30
+ person.account = nil if person.account
31
+ end
32
+
27
33
  end
data/lib/eco/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Eco
2
- VERSION = "2.0.12"
2
+ VERSION = "2.0.13"
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.12
4
+ version: 2.0.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oscar Segura