eco-helpers 1.5.7 → 1.5.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/lib/eco/api/session.rb +4 -2
- data/lib/eco/api/session/batch/job.rb +1 -1
- data/lib/eco/api/session/batch/jobs.rb +22 -3
- data/lib/eco/api/session/batch/jobs_groups.rb +9 -0
- data/lib/eco/api/usecases/default_cases/refresh_case.rb +1 -1
- data/lib/eco/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2b5a4fcfab321e9a7071a18fb52c38c21a67314a44a2edda63f4783de6ea9f38
|
4
|
+
data.tar.gz: 20b067294c6e2d47c6efa09c62052d2081ce3a56252216fb11c9e465ed0fc5af
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 92bc7a1814a8654bc9831ca8e763802ad40f0679c7ee31bc26b2146f7006744b576fa7586c16b2bd50deb1b74738c41d08d14e47b41fd3d34fd299d753213bb1
|
7
|
+
data.tar.gz: 1dbdacf348a3ec57718dbf15dc825adf97839ea070ae0463b4df1a8a020c3c8bee8edc5b3903029d57f112a8517f20ac0870a5b73a206257be21d27e425c66f2
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,15 @@
|
|
1
1
|
# Change Log
|
2
2
|
All notable changes to this project will be documented in this file.
|
3
3
|
|
4
|
+
## [1.5.8] - 2020-12-xx
|
5
|
+
|
6
|
+
### Added
|
7
|
+
### Changed
|
8
|
+
### Fixed
|
9
|
+
- `Eco::API::Session::Batch::Jobs#job` shouldn't be calling the post-launch callback function on creation.
|
10
|
+
- `Eco::API::Session#new_job` should include a `&block` parameter.
|
11
|
+
- `Eco::API::UseCases::DefaultCases::RefreshCase`: fixed typo
|
12
|
+
|
4
13
|
## [1.5.7] - 2020-12-17
|
5
14
|
|
6
15
|
### Added
|
data/lib/eco/api/session.rb
CHANGED
@@ -217,6 +217,7 @@ module Eco
|
|
217
217
|
@job_groups ||= Batch::JobsGroups.new(enviro)
|
218
218
|
end
|
219
219
|
|
220
|
+
# It retrives the group of `Batch::Jobs` named `name`. It creates it if it doesn't exist.
|
220
221
|
# @return [Eco::API::Session::Batch::Jobs]
|
221
222
|
def job_group(name, order: :last)
|
222
223
|
case
|
@@ -228,9 +229,10 @@ module Eco
|
|
228
229
|
end
|
229
230
|
|
230
231
|
# Shortcut to create a job of certain type within a group
|
232
|
+
# @param [see @Eco::API::Session::Batch::Jobs#new]
|
231
233
|
# @return [Eco::API::Session::Batch::Job]
|
232
|
-
def new_job(group, name, type, usecase, sets = [:core, :details, :account])
|
233
|
-
job_group(group).new(name, usecase: usecase, type: type, sets: sets)
|
234
|
+
def new_job(group, name, type, usecase, sets = [:core, :details, :account], &block)
|
235
|
+
job_group(group).new(name, usecase: usecase, type: type, sets: sets, &block)
|
234
236
|
end
|
235
237
|
|
236
238
|
# @see Eco::API::Session::Batch::JobsGroups#launch
|
@@ -96,7 +96,7 @@ module Eco
|
|
96
96
|
# @param entry [Ecoportal::API::V1::Person, Enumberable<Person>] the person(s) we want to update, carrying the changes to be done.
|
97
97
|
# @param unique [Boolean] specifies if repeated entries should be avoided in the queue.
|
98
98
|
# @yield [person] callback before launching the batch job request against the server.
|
99
|
-
# @yieldparam
|
99
|
+
# @yieldparam person [Person] current person object that that should be treated by the callback before launching the batch.
|
100
100
|
# @return [Eco::API::Session::Batch::Job] this `Batch::Job`.
|
101
101
|
def add(entry, unique: true, &block)
|
102
102
|
case entry
|
@@ -42,13 +42,23 @@ module Eco
|
|
42
42
|
@jobs.key?(name)
|
43
43
|
end
|
44
44
|
|
45
|
+
# It retrieves an existing job named `name` or creates it if it doesn't exist.
|
46
|
+
# @note
|
47
|
+
# - the block should only be passed when creating the job
|
48
|
+
# @param [see @Eco::API::Session::Batch::Jobs#new]
|
49
|
+
# @return [Eco::API::Session::Batch::Job]
|
45
50
|
def job(name, type: nil, sets: nil, usecase: nil, &block)
|
51
|
+
fatal "Can't give a job post-launch callback &block to an already existing job" if exists?(name)
|
46
52
|
new(name, type: type, sets: sets, usecase: usecase, &block) unless exists?(name)
|
47
|
-
self[name]
|
48
|
-
block.call(job) if block
|
49
|
-
end
|
53
|
+
self[name]
|
50
54
|
end
|
51
55
|
|
56
|
+
# Creates a new `Batch::Job` included as part of this `Batch::Jobs`.
|
57
|
+
# @param [see Eco::API::Session::Job#new]
|
58
|
+
# @yield [job, status] callback after launching the batch job request against the server.
|
59
|
+
# @yieldparam job [Eco::API::Session::Batch::Job] the job we have launched against the server.
|
60
|
+
# @yieldparam status [Eco::API::Session::Batch::Status] the status of the batch job launch.
|
61
|
+
# @return [Eco::API::Session::Batch::Job]
|
52
62
|
def new(name, type:, sets:, usecase: nil, &block)
|
53
63
|
fatal "Can't create job named '#{name}' because it already exists." if exists?(name)
|
54
64
|
|
@@ -57,6 +67,11 @@ module Eco
|
|
57
67
|
end
|
58
68
|
end
|
59
69
|
|
70
|
+
# @param job [Eco::API::Session::Batch::Job] the `Batch::Job` to add.
|
71
|
+
# @yield [job, status] callback after launching the batch job request against the server.
|
72
|
+
# @yieldparam job [Eco::API::Session::Batch::Job] the job we have launched against the server.
|
73
|
+
# @yieldparam status [Eco::API::Session::Batch::Status] the status of the batch job launch.
|
74
|
+
# @return [Eco::API::Session::Batch::Job]
|
60
75
|
def add(job)
|
61
76
|
fatal "Expected Eco::API::Session::Batch::Job object. Given #{job.class}" unless job.is_a?(Eco::API::Session::Batch::Job)
|
62
77
|
@jobs[job.name] = job
|
@@ -67,6 +82,10 @@ module Eco
|
|
67
82
|
any? {|job| job.pending?}
|
68
83
|
end
|
69
84
|
|
85
|
+
# Launches every `Batch::Job` in the group.
|
86
|
+
# @note
|
87
|
+
# - if there was post-launch callback for a `Batch::Job`, it calls it.
|
88
|
+
# @return [Hash<Eco::API::Session::Batch::Job, Eco::API::Session::Batch::Status>]
|
70
89
|
def launch(simulate: false)
|
71
90
|
each do |job|
|
72
91
|
if job.pending?
|
@@ -58,6 +58,11 @@ module Eco
|
|
58
58
|
@groups.key?(name)
|
59
59
|
end
|
60
60
|
|
61
|
+
# Creates a new group of `Batch::Jobs` named `name`.
|
62
|
+
# @yield [group, group_status] callback after launching the batch job request against the server.
|
63
|
+
# @yieldparam group [Eco::API::Session::Batch::Jobs] the group of jobs we have launched against the server.
|
64
|
+
# @yieldparam group_status [Hash<Eco::API::Session::Batch::Job, Eco::API::Session::Batch::Status>] the status of the launched batch jobs.
|
65
|
+
# @return [Eco::API::Session::Batch::Jobs] the group of jobs.
|
61
66
|
def new(name, order: :last)
|
62
67
|
fatal "Can't create job group named '#{name}' because it already exists." if exists?(name)
|
63
68
|
|
@@ -78,6 +83,10 @@ module Eco
|
|
78
83
|
any? {|group| group.pending?}
|
79
84
|
end
|
80
85
|
|
86
|
+
# Launches every `Batch::Jobs` group in the current `Batch::JobGroups`
|
87
|
+
# @note
|
88
|
+
# - if there was post-launch callback for a `Batch::Jobs` groups, it calls it.
|
89
|
+
# @return [Hash<Eco::API::Session::Batch::Jobs,Hash<Eco::API::Session::Batch::Job, Eco::API::Session::Batch::Status>>]
|
81
90
|
def launch(simulate: false)
|
82
91
|
@order.each_with_index do |group, idx|
|
83
92
|
if group.pending?
|
@@ -4,7 +4,7 @@ class Eco::API::UseCases::DefaultCases::RefreshCase < Eco::API::Common::Loaders:
|
|
4
4
|
|
5
5
|
def main(people, session, options, usecase)
|
6
6
|
update = session.new_job("main", "update", :update, usecase)
|
7
|
-
people.each {|person|
|
7
|
+
people.each {|person| update.add(person)}
|
8
8
|
end
|
9
9
|
|
10
10
|
end
|
data/lib/eco/version.rb
CHANGED