eco-helpers 2.0.48 → 2.0.49
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -1
- data/lib/eco/api/session/batch/request_stats.rb +50 -34
- data/lib/eco/api/usecases/default_cases/reinvite_trans_case.rb +13 -4
- data/lib/eco/api/usecases/default_cases/samples/sftp_case.rb +1 -1
- data/lib/eco/cli/config/default/usecases.rb +6 -0
- 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: 9b4a2ad99ea2e78519b611cdcdb74743ae9dd1a8f5707164ebcc686c21d83700
|
4
|
+
data.tar.gz: b9387499878102825b1396bf35394cc12c35c4b738380f3bfd52e2407c4239af
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d574a346ba439207b85cfd1e265ed4b3c3f3742dd6308adfc8a873717bea8fd0f9ceaec49fcde1ea5575068c4e00395a4a200b42d624b45e707bd89d68b4560a
|
7
|
+
data.tar.gz: 99a77ede34b322d1ebe6ad54822db841ae111e7063a4dbd6317dd092222a43919e8e059536db9f9c386bbbc31cd8043e64192f425a4fae055f3511ae6f622e67
|
data/CHANGELOG.md
CHANGED
@@ -1,9 +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.
|
4
|
+
## [2.0.49] - 2022-02-14
|
5
5
|
|
6
6
|
### Added
|
7
|
+
- `Eco::API::Session::Batch::RequestStats#message` now it shows which details have changed
|
8
|
+
- `Eco::API::UseCases::DefaultCases::ReinviteTransCase` the option `-force` will also send an invite to users that have accepted the invitation
|
9
|
+
|
10
|
+
### Changed
|
11
|
+
### Fixed
|
12
|
+
|
13
|
+
## [2.0.48] - 2022-02-04
|
14
|
+
|
7
15
|
### Changed
|
8
16
|
- upgraded `ecoportal-api-v2` dependency
|
9
17
|
|
@@ -9,6 +9,7 @@ module Eco
|
|
9
9
|
ACCOUNT_ATTRS = (Eco::API::Common::People::PersonParser::ACCOUNT_ATTRS + ["permissions_custom"]).uniq
|
10
10
|
DETAILS_ATTRS = ["fields"]
|
11
11
|
BLANKED_PREFIX = "blanked_"
|
12
|
+
DETAILS_FIELDS = "details_fields"
|
12
13
|
|
13
14
|
class << self
|
14
15
|
|
@@ -74,44 +75,43 @@ module Eco
|
|
74
75
|
end
|
75
76
|
|
76
77
|
def message(percent: false)
|
77
|
-
key_val_delimiter = ": "; attr_delimiter = " ++ "
|
78
|
-
pairs_to_line = Proc.new do |pairs|
|
79
|
-
pairs.map do |p|
|
80
|
-
[p.first.to_s, "#{p.last.to_s}" + (percent ? "%" : "")].join(key_val_delimiter)
|
81
|
-
end.join(attr_delimiter)
|
82
|
-
end
|
83
|
-
|
84
78
|
lines = []
|
85
|
-
lines << pairs_to_line
|
86
|
-
lines << pairs_to_line
|
87
|
-
lines << pairs_to_line
|
79
|
+
lines << pairs_to_line(core_pairs(percent: percent))
|
80
|
+
lines << pairs_to_line(account_pairs(percent: percent))
|
81
|
+
lines << pairs_to_line(details_pairs(percent: percent))
|
88
82
|
lines.join("\n")
|
89
83
|
end
|
90
84
|
|
91
85
|
private
|
92
86
|
|
93
|
-
def
|
94
|
-
|
87
|
+
def attr_value(attr, percent: false, total: count, details: false)
|
88
|
+
target = details ? (@stats[DETAILS_FIELDS] || {}) : @stats
|
89
|
+
i = target["#{attr}"]
|
95
90
|
return i unless percent
|
96
91
|
percentage(i, total: total)
|
97
92
|
end
|
98
93
|
|
99
94
|
def core(percent: false)
|
100
|
-
|
95
|
+
attr_value("core", percent: percent)
|
101
96
|
end
|
102
97
|
|
103
98
|
def account(percent: false)
|
104
|
-
|
99
|
+
attr_value("account", percent: percent)
|
105
100
|
end
|
106
101
|
|
107
102
|
def details(percent: false)
|
108
|
-
|
103
|
+
attr_value("details", percent: percent)
|
104
|
+
end
|
105
|
+
|
106
|
+
def stats
|
107
|
+
@stats ||= Hash.new(0)
|
109
108
|
end
|
110
109
|
|
111
110
|
def build(requests)
|
112
|
-
|
111
|
+
stats.tap do |stats|
|
113
112
|
stats[type] = count
|
114
113
|
unless !requests || !requests.is_a?(Enumerable) || requests.empty?
|
114
|
+
stats[DETAILS_FIELDS] = Hash.new(0)
|
115
115
|
requests.each_with_index do |request|
|
116
116
|
add_core_stats(stats, request || {})
|
117
117
|
add_account_stats(stats, request || {})
|
@@ -149,16 +149,15 @@ module Eco
|
|
149
149
|
if request.key?("details")
|
150
150
|
stats["details"] += 1
|
151
151
|
stats["details_remove"] += 1 if !request["details"]
|
152
|
+
|
153
|
+
det_attrs = {}
|
152
154
|
if fields = request.dig("details", "fields")
|
153
155
|
stats["fields"] += fields.length
|
156
|
+
det_attrs = fields.each_with_object(det_attrs) {|fld, hash| hash[fld["alt_id"]] = fld["value"]}
|
154
157
|
end
|
155
|
-
end
|
156
|
-
end
|
157
158
|
|
158
|
-
|
159
|
-
|
160
|
-
(v = attr(a, percent: percent, total: count)) > 0 ? [a, v] : nil
|
161
|
-
end.compact
|
159
|
+
attrs_to_stat(stats[DETAILS_FIELDS], det_attrs, det_attrs.keys)
|
160
|
+
end
|
162
161
|
end
|
163
162
|
|
164
163
|
def core_pairs(percent: false)
|
@@ -172,22 +171,23 @@ module Eco
|
|
172
171
|
end
|
173
172
|
|
174
173
|
def details_pairs(percent: false)
|
175
|
-
|
176
|
-
|
177
|
-
|
174
|
+
det_pairs = [["details", details(percent: percent)]]
|
175
|
+
det_pairs += [["fields", fields_average]] if attr_value("fields") && fields_average
|
176
|
+
det_pairs += pairs(["details_remove"], percent: percent, total: details)
|
177
|
+
det_pairs += pairs(details_field_attrs, percent: percent, total: details, details: true)
|
178
178
|
end
|
179
179
|
|
180
|
-
def
|
181
|
-
|
182
|
-
(
|
183
|
-
end
|
180
|
+
def pairs(attrs, percent: false, total: count, details: false)
|
181
|
+
pairs = attrs.map do |a|
|
182
|
+
(v = attr_value(a, percent: percent, total: count, details: details)) > 0 ? [a, v] : nil
|
183
|
+
end.compact
|
184
184
|
end
|
185
185
|
|
186
|
-
def
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
end
|
186
|
+
def pairs_to_line(pairs, percent: false)
|
187
|
+
key_val_delimiter = ": "; attr_delimiter = " ++ "
|
188
|
+
pairs.map do |p|
|
189
|
+
[p.first.to_s, "#{p.last.to_s}" + (percent ? "%" : "")].join(key_val_delimiter)
|
190
|
+
end.join(attr_delimiter)
|
191
191
|
end
|
192
192
|
|
193
193
|
def core_attrs
|
@@ -202,6 +202,10 @@ module Eco
|
|
202
202
|
@details_attrs ||= self.class.details_attrs
|
203
203
|
end
|
204
204
|
|
205
|
+
def details_field_attrs
|
206
|
+
@stats[DETAILS_FIELDS].keys
|
207
|
+
end
|
208
|
+
|
205
209
|
def blank_attrs(attrs)
|
206
210
|
self.class.blank_attrs(attrs)
|
207
211
|
end
|
@@ -225,6 +229,18 @@ module Eco
|
|
225
229
|
end
|
226
230
|
end
|
227
231
|
|
232
|
+
def fields_average
|
233
|
+
if (fields_num = attr_value("fields")) && (total = details) > 0
|
234
|
+
(fields_num.to_f / total.to_f).round(2)
|
235
|
+
end
|
236
|
+
end
|
237
|
+
|
238
|
+
def percentage(num, total: count)
|
239
|
+
total ||= count
|
240
|
+
if num
|
241
|
+
(num.to_f / total * 100).round(2)
|
242
|
+
end
|
243
|
+
end
|
228
244
|
end
|
229
245
|
end
|
230
246
|
end
|
@@ -2,16 +2,25 @@ class Eco::API::UseCases::DefaultCases::ReinviteTransCase < Eco::API::Common::Lo
|
|
2
2
|
name "reinvite"
|
3
3
|
type :transform
|
4
4
|
|
5
|
+
def main(people, session, options, usecase)
|
6
|
+
reinvite(people.users, session, options, usecase)
|
7
|
+
end
|
8
|
+
|
9
|
+
private
|
10
|
+
|
5
11
|
def reinvite(users, session, options, usecase)
|
6
12
|
invite = session.new_job("main", "invite", :update, usecase, :account)
|
7
13
|
users.each do |person|
|
8
|
-
|
14
|
+
if force_invite?
|
15
|
+
person.account.send_invites = true
|
16
|
+
else
|
17
|
+
person.account.force_send_invites = true
|
18
|
+
end
|
9
19
|
invite.add(person)
|
10
20
|
end
|
11
21
|
end
|
12
22
|
|
13
|
-
def
|
14
|
-
|
23
|
+
def force_invite?
|
24
|
+
options.dig(:force, :invite)
|
15
25
|
end
|
16
|
-
|
17
26
|
end
|
@@ -28,7 +28,7 @@ class Eco::API::UseCases::DefaultCases::Samples::Sftp < Eco::API::Common::Loader
|
|
28
28
|
|
29
29
|
# Ex: "/IN/Personnel"
|
30
30
|
def remote_subfolder
|
31
|
-
raise "You should redefine remote_subfolder as the folder where the target file sits"
|
31
|
+
raise "You should redefine remote_subfolder as the folder where the target file sits. Ex: /IN/Personnel"
|
32
32
|
end
|
33
33
|
|
34
34
|
def archive_subfolder
|
@@ -183,9 +183,15 @@ ASSETS.cli.config do |cnf|
|
|
183
183
|
|
184
184
|
desc = "Re-sends invites to all filtered users that have not accepted the invite as yet"
|
185
185
|
cases.add("-reinvite", :transform, desc, case_name: "reinvite")
|
186
|
+
.add_option("-force", "If also send an invite email to those that have accepted the invite") do |options|
|
187
|
+
options.deep_merge!(force: {invite: true})
|
188
|
+
end
|
186
189
|
|
187
190
|
desc = "Re-sends invites to target users that have not accepted the invite as yet"
|
188
191
|
cases.add("-reinvite-from", :sync, desc, case_name: "reinvite")
|
192
|
+
.add_option("-force", "If also send an invite email to those that have accepted the invite") do |options|
|
193
|
+
options.deep_merge!(force: {invite: true})
|
194
|
+
end
|
189
195
|
|
190
196
|
desc = "Deletes everybody that has been filtered from the people manager"
|
191
197
|
cases.add("-delete", :transform, desc, case_name: "delete")
|
data/lib/eco/version.rb
CHANGED