eco-helpers 1.3.15 → 1.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +52 -0
- data/eco-helpers.gemspec +6 -6
- data/lib/eco/api/common/people/entries.rb +10 -5
- data/lib/eco/api/common/version_patches/ecoportal_api.rb +0 -4
- data/lib/eco/api/common/version_patches/ecoportal_api/external_person.rb +0 -4
- data/lib/eco/api/organization/presets_reference.json +12 -3
- data/lib/eco/api/organization/presets_values.json +3 -1
- data/lib/eco/api/session/batch/errors.rb +9 -7
- data/lib/eco/api/usecases/default_cases/create_case.rb +1 -1
- data/lib/eco/api/usecases/default_cases/hris_case.rb +7 -6
- data/lib/eco/api/usecases/default_cases/set_default_tag_case.rb +6 -2
- data/lib/eco/api/usecases/default_cases/to_csv_case.rb +1 -1
- data/lib/eco/api/usecases/default_cases/to_csv_detailed_case.rb +1 -1
- data/lib/eco/api/usecases/default_cases/update_case.rb +6 -1
- data/lib/eco/api/usecases/default_cases/upsert_case.rb +1 -1
- data/lib/eco/data/files/helpers.rb +1 -1
- data/lib/eco/version.rb +1 -1
- metadata +29 -26
- data/lib/eco/api/common/version_patches/ecoportal_api/account_preferences.rb +0 -51
- data/lib/eco/api/common/version_patches/ecoportal_api/base_model.rb +0 -27
- data/lib/eco/api/common/version_patches/ecoportal_api/external_people.rb +0 -38
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b8549b3b32c04e66cfcf581fe12a2ea13deab952bc631476d5997eb2c722b7ba
|
4
|
+
data.tar.gz: 5e91c6a4a539791cc5fe30049b22d63d030f53e42781cce7500fadaba8b0fe91
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dbf7e479462ad4aadfd47e2140c02294901a1eb95f59d93e621911eb69527be3f6f8c4634d6f6d14a174331633b91fae9329ef8681b49e9c363a9f0db0a659ab
|
7
|
+
data.tar.gz: e3a1c26324ca0f5386776dafde22d71effe62cb4b2756ac53962783be3d9cfcef83966251fe93073178725a1ffa39103ca84da24b3ace5bfbd1877d1fba64d67
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,58 @@
|
|
1
1
|
# Change Log
|
2
2
|
All notable changes to this project will be documented in this file.
|
3
3
|
|
4
|
+
## [1.4.1] - 2020-07-23
|
5
|
+
|
6
|
+
### Added
|
7
|
+
### Changed
|
8
|
+
### Fixed
|
9
|
+
- preserve backtrace on logging
|
10
|
+
|
11
|
+
## [1.4.0] - 2020-07-14
|
12
|
+
|
13
|
+
### Added
|
14
|
+
### Changed
|
15
|
+
- change abilities to align with ecoPortal release `1.5.0`
|
16
|
+
- remove some patches on `ecoportal-api`
|
17
|
+
- removed patch method `Ecoportal::API::V1::Person#sync`
|
18
|
+
### Fixed
|
19
|
+
- `Eco::CSV#parse` and `Eco::CSV#read` should use the proper `:encoding` when it's `bom`
|
20
|
+
|
21
|
+
## [1.3.19] - 2020-07-23
|
22
|
+
|
23
|
+
### Added
|
24
|
+
### Changed
|
25
|
+
### Fixed
|
26
|
+
- preserve backtrace on logging
|
27
|
+
|
28
|
+
## [1.3.18] - 2020-07-08
|
29
|
+
|
30
|
+
### Added
|
31
|
+
### Changed
|
32
|
+
### Fixed
|
33
|
+
- the `update` case was missing the code to use the `default_usergroup`
|
34
|
+
|
35
|
+
|
36
|
+
## [1.3.17] - 2020-07-06
|
37
|
+
|
38
|
+
### Added
|
39
|
+
### Changed
|
40
|
+
- the `hris` case should not only include as `leavers` those that have account, but anyone that leaves
|
41
|
+
* as we could have active people with no account
|
42
|
+
### Fixed
|
43
|
+
- `Eco::API::Session::Batch::Errors#errors`: fix error for empty `body` on response
|
44
|
+
|
45
|
+
## [1.3.16] - 2020-06-26
|
46
|
+
|
47
|
+
### Added
|
48
|
+
- `Eco::API::Common::People::Entries`, `#entry` & `#find` should allow for `strict` search (added parameter)
|
49
|
+
### Changed
|
50
|
+
- upgraded `ecoportal-api` gem dependency to minimum version `0.5.7`
|
51
|
+
- this includes the removal of some patches
|
52
|
+
- some gems update
|
53
|
+
### Fixed
|
54
|
+
- patched preferences (`kiosk` preferences should default to `nil`)
|
55
|
+
|
4
56
|
## [1.3.15] - 2020-06-11
|
5
57
|
|
6
58
|
### Added
|
data/eco-helpers.gemspec
CHANGED
@@ -22,16 +22,16 @@ Gem::Specification.new do |s|
|
|
22
22
|
#s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
23
23
|
s.require_paths = ["lib"]
|
24
24
|
|
25
|
-
s.add_development_dependency "bundler", "~> 2.
|
26
|
-
s.add_development_dependency "rspec", "~> 3", ">= 3.
|
25
|
+
s.add_development_dependency "bundler", "~> 2.1", ">= 2.1.3"
|
26
|
+
s.add_development_dependency "rspec", "~> 3", ">= 3.9"
|
27
27
|
s.add_development_dependency "rake", "~> 12.3.0"
|
28
28
|
s.add_development_dependency "yard", "~> 0.9", ">= 0.9.18"
|
29
29
|
s.add_development_dependency "redcarpet", "~> 3.5", ">= 3.5.0"
|
30
30
|
|
31
|
-
s.add_dependency 'ecoportal-api', '~> 0.5', '>= 0.5.
|
32
|
-
s.add_dependency 'aws-sdk-s3', '~> 1
|
33
|
-
s.add_dependency 'aws-sdk-ses', '~> 1
|
34
|
-
s.add_dependency 'dotenv', '~> 2.
|
31
|
+
s.add_dependency 'ecoportal-api', '~> 0.5', '>= 0.5.9'
|
32
|
+
s.add_dependency 'aws-sdk-s3', '~> 1', '>= 1.64.0'
|
33
|
+
s.add_dependency 'aws-sdk-ses', '~> 1', '>= 1.29.0'
|
34
|
+
s.add_dependency 'dotenv', '~> 2.7', '>= 2.7.0'
|
35
35
|
s.add_dependency 'net-sftp', '~> 2.1', '>= 2.1.2'
|
36
36
|
|
37
37
|
end
|
@@ -50,23 +50,28 @@ module Eco
|
|
50
50
|
end
|
51
51
|
|
52
52
|
# Search function to find an `entry` based on one of different options
|
53
|
-
def entry(id: nil, external_id: nil, email: nil)
|
53
|
+
def entry(id: nil, external_id: nil, email: nil, strict: false)
|
54
54
|
init_caches
|
55
55
|
pers = nil
|
56
56
|
pers = @by_id[id]&.first if id
|
57
57
|
pers = @by_external_id[external_id&.strip]&.first if !pers && !external_id.to_s.strip.empty?
|
58
|
-
|
59
|
-
|
58
|
+
|
59
|
+
# strict prevents taking existing user for searched person with same email
|
60
|
+
# specially useful if the organisation ensures all have external id (no need for email search)
|
61
|
+
if !pers && (!strict || external_id.to_s.strip.empty?)
|
62
|
+
pers = @by_email[email&.downcase.strip]&.first if !pers && !email.to_s.strip.empty?
|
63
|
+
pers = @by_external_id[email&.downcase.strip]&.first if !pers && !email.to_s.strip.empty?
|
64
|
+
end
|
60
65
|
pers
|
61
66
|
end
|
62
67
|
|
63
68
|
# Search function to find an `entry` based on one of different options
|
64
69
|
# see Eco::API::Common::People::Entries#entry
|
65
|
-
def find(object)
|
70
|
+
def find(object, strict: false)
|
66
71
|
id = object.respond_to?("id")? object.send("id") : nil
|
67
72
|
external_id = object.respond_to?("external_id")? object.send("external_id") : nil
|
68
73
|
email = object.respond_to?("email")? object.send("email") : nil
|
69
|
-
entry(id: id, external_id: external_id, email: email)
|
74
|
+
entry(id: id, external_id: external_id, email: email, strict: strict)
|
70
75
|
end
|
71
76
|
|
72
77
|
def exclude(object)
|
@@ -1,6 +1,2 @@
|
|
1
|
-
require 'ecoportal/api'
|
2
|
-
require_relative 'ecoportal_api/base_model'
|
3
|
-
require_relative 'ecoportal_api/external_people'
|
4
1
|
require_relative 'ecoportal_api/external_person'
|
5
2
|
require_relative 'ecoportal_api/internal_person'
|
6
|
-
require_relative 'ecoportal_api/account_preferences'
|
@@ -5,6 +5,9 @@
|
|
5
5
|
"reports": "view",
|
6
6
|
"organization": null,
|
7
7
|
"people": null,
|
8
|
+
"person_core": null,
|
9
|
+
"person_account": null,
|
10
|
+
"person_details": null,
|
8
11
|
"pages": "view",
|
9
12
|
"page_editor": null,
|
10
13
|
"registers": "view"
|
@@ -14,7 +17,9 @@
|
|
14
17
|
"data": "view",
|
15
18
|
"reports": "view",
|
16
19
|
"organization": null,
|
17
|
-
"
|
20
|
+
"person_core": "attach",
|
21
|
+
"person_account": null,
|
22
|
+
"person_details": "view",
|
18
23
|
"pages": "create",
|
19
24
|
"page_editor": "basic",
|
20
25
|
"registers": "view"
|
@@ -24,7 +29,9 @@
|
|
24
29
|
"data": "update",
|
25
30
|
"reports": "edit",
|
26
31
|
"organization": "view",
|
27
|
-
"
|
32
|
+
"person_core": "view_people_manager",
|
33
|
+
"person_account": "view",
|
34
|
+
"person_details": "view",
|
28
35
|
"pages": "create",
|
29
36
|
"page_editor": "intermediate",
|
30
37
|
"registers": "view"
|
@@ -34,7 +41,9 @@
|
|
34
41
|
"data": "administrate",
|
35
42
|
"reports": "administrate",
|
36
43
|
"organization": "administrate",
|
37
|
-
"
|
44
|
+
"person_core": "edit",
|
45
|
+
"person_account": "edit",
|
46
|
+
"person_details": "edit_private",
|
38
47
|
"pages": "administrate",
|
39
48
|
"page_editor": "advanced",
|
40
49
|
"registers": "dashboard"
|
@@ -3,7 +3,9 @@
|
|
3
3
|
"data": [null, "view", "update", "administrate", "implement"],
|
4
4
|
"reports": [null, "view", "edit", "administrate"],
|
5
5
|
"organization": [null, "view", "administrate", "implement"],
|
6
|
-
"
|
6
|
+
"person_core": [null, "attach", "view_people_manager", "create", "edit", "dashboard"],
|
7
|
+
"person_account": [null, "view", "create", "edit"],
|
8
|
+
"person_details": [null, "view", "edit_public", "view_private", "edit_private"],
|
7
9
|
"pages": [null, "view", "update", "create", "administrate"],
|
8
10
|
"page_editor": [null, "basic", "intermediate", "advanced", "implement"],
|
9
11
|
"registers": [null, "view", "dashboard", "administrate", "implement"]
|
@@ -69,13 +69,15 @@ module Eco
|
|
69
69
|
|
70
70
|
def errors
|
71
71
|
entries.each_with_object([]) do |entry, arr|
|
72
|
-
if
|
73
|
-
errs
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
72
|
+
if body = status[entry].body
|
73
|
+
if errs = body["errors"]
|
74
|
+
errs.each do |msg|
|
75
|
+
arr.push({
|
76
|
+
type: klass = Eco::API::Error.get_type(msg),
|
77
|
+
err: klass.new(err_msg: msg, entry: entry, session: session),
|
78
|
+
entry: entry
|
79
|
+
})
|
80
|
+
end
|
79
81
|
end
|
80
82
|
end
|
81
83
|
end
|
@@ -69,7 +69,7 @@ module Eco
|
|
69
69
|
if session.tagtree
|
70
70
|
person.account.default_tag = session.tagtree.default_tag(*person.filter_tags)
|
71
71
|
else
|
72
|
-
tags = person.filter_tags
|
72
|
+
tags = person.filter_tags || []
|
73
73
|
person.account.default_tag = tags.first unless tags.length > 1
|
74
74
|
end
|
75
75
|
end
|
@@ -11,17 +11,18 @@ module Eco
|
|
11
11
|
supers = session.job_group("post").new("supers", usecase: usecase, type: :update, sets: :core)
|
12
12
|
leavers = session.job_group("post").new("leavers", usecase: usecase, type: :update, sets: :account)
|
13
13
|
|
14
|
-
people.
|
15
|
-
|
14
|
+
strict_search = session.config.people.strict_search? && (!options[:search]&.key?(:strict) || options.dig(:search, :strict))
|
15
|
+
pgs = session.policy_groups
|
16
|
+
|
17
|
+
people.each_with_index do |person, i|
|
18
|
+
if !entries.find(person, strict: strict_search)
|
16
19
|
leavers.add(person) do |person|
|
17
20
|
person.supervisor_id = nil
|
18
|
-
person.account = nil
|
21
|
+
person.account = nil if person.account
|
19
22
|
end
|
20
23
|
end
|
21
24
|
end
|
22
25
|
|
23
|
-
strict_search = session.config.people.strict_search? && (!options[:search]&.key?(:strict) || options.dig(:search, :strict))
|
24
|
-
pgs = session.policy_groups
|
25
26
|
|
26
27
|
if session.config.people.default_usergroup?
|
27
28
|
def_id = pgs.to_id(session.config.people.default_usergroup)
|
@@ -84,7 +85,7 @@ module Eco
|
|
84
85
|
if session.tagtree
|
85
86
|
person.account.default_tag = session.tagtree.default_tag(*person.filter_tags)
|
86
87
|
else
|
87
|
-
tags = person.filter_tags
|
88
|
+
tags = person.filter_tags || []
|
88
89
|
person.account.default_tag = tags.first unless tags.length > 1
|
89
90
|
end
|
90
91
|
end
|
@@ -30,8 +30,12 @@ module Eco
|
|
30
30
|
update = session.job_group("main").new("update", usecase: usecase, type: :update, sets: :account)
|
31
31
|
|
32
32
|
people.each_with_index do |person, i|
|
33
|
-
|
34
|
-
|
33
|
+
if session.tagtree
|
34
|
+
person.account.default_tag = session.tagtree.default_tag(*person.filter_tags)
|
35
|
+
else
|
36
|
+
tags = person.filter_tags || []
|
37
|
+
person.account.default_tag = tags.first unless tags.length > 1
|
38
|
+
end
|
35
39
|
update.add(person)
|
36
40
|
end
|
37
41
|
|
@@ -12,6 +12,10 @@ module Eco
|
|
12
12
|
strict_search = session.config.people.strict_search? && (!options[:search]&.key?(:strict) || options.dig(:search, :strict))
|
13
13
|
pgs = session.policy_groups
|
14
14
|
|
15
|
+
if session.config.people.default_usergroup?
|
16
|
+
def_id = pgs.to_id(session.config.people.default_usergroup)
|
17
|
+
end
|
18
|
+
|
15
19
|
entries.each.with_index do |entry, i|
|
16
20
|
if person = people.find(entry, strict: strict_search)
|
17
21
|
|
@@ -37,6 +41,7 @@ module Eco
|
|
37
41
|
entry.set_details(person) unless options.dig(:exclude, :details)
|
38
42
|
|
39
43
|
unless options.dig(:exclude, :account)
|
44
|
+
add_account = !person.account
|
40
45
|
ini_pg_ids = person.account&.policy_group_ids || []
|
41
46
|
|
42
47
|
account_excluded = []
|
@@ -68,7 +73,7 @@ module Eco
|
|
68
73
|
if session.tagtree
|
69
74
|
person.account.default_tag = session.tagtree.default_tag(*person.filter_tags)
|
70
75
|
else
|
71
|
-
tags = person.filter_tags
|
76
|
+
tags = person.filter_tags || []
|
72
77
|
person.account.default_tag = tags.first unless tags.length > 1
|
73
78
|
end
|
74
79
|
end
|
@@ -77,7 +77,7 @@ module Eco
|
|
77
77
|
if session.tagtree
|
78
78
|
person.account.default_tag = session.tagtree.default_tag(*person.filter_tags)
|
79
79
|
else
|
80
|
-
tags = person.filter_tags
|
80
|
+
tags = person.filter_tags || []
|
81
81
|
person.account.default_tag = tags.first unless tags.length > 1
|
82
82
|
end
|
83
83
|
end
|
data/lib/eco/version.rb
CHANGED
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: 1.
|
4
|
+
version: 1.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Oscar Segura
|
@@ -16,14 +16,20 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 2.
|
19
|
+
version: '2.1'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 2.1.3
|
20
23
|
type: :development
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
27
|
- - "~>"
|
25
28
|
- !ruby/object:Gem::Version
|
26
|
-
version: 2.
|
29
|
+
version: '2.1'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 2.1.3
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: rspec
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -33,7 +39,7 @@ dependencies:
|
|
33
39
|
version: '3'
|
34
40
|
- - ">="
|
35
41
|
- !ruby/object:Gem::Version
|
36
|
-
version: '3.
|
42
|
+
version: '3.9'
|
37
43
|
type: :development
|
38
44
|
prerelease: false
|
39
45
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -43,7 +49,7 @@ dependencies:
|
|
43
49
|
version: '3'
|
44
50
|
- - ">="
|
45
51
|
- !ruby/object:Gem::Version
|
46
|
-
version: '3.
|
52
|
+
version: '3.9'
|
47
53
|
- !ruby/object:Gem::Dependency
|
48
54
|
name: rake
|
49
55
|
requirement: !ruby/object:Gem::Requirement
|
@@ -107,7 +113,7 @@ dependencies:
|
|
107
113
|
version: '0.5'
|
108
114
|
- - ">="
|
109
115
|
- !ruby/object:Gem::Version
|
110
|
-
version: 0.5.
|
116
|
+
version: 0.5.9
|
111
117
|
type: :runtime
|
112
118
|
prerelease: false
|
113
119
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -117,67 +123,67 @@ dependencies:
|
|
117
123
|
version: '0.5'
|
118
124
|
- - ">="
|
119
125
|
- !ruby/object:Gem::Version
|
120
|
-
version: 0.5.
|
126
|
+
version: 0.5.9
|
121
127
|
- !ruby/object:Gem::Dependency
|
122
128
|
name: aws-sdk-s3
|
123
129
|
requirement: !ruby/object:Gem::Requirement
|
124
130
|
requirements:
|
125
131
|
- - "~>"
|
126
132
|
- !ruby/object:Gem::Version
|
127
|
-
version: '1
|
133
|
+
version: '1'
|
128
134
|
- - ">="
|
129
135
|
- !ruby/object:Gem::Version
|
130
|
-
version: 1.
|
136
|
+
version: 1.64.0
|
131
137
|
type: :runtime
|
132
138
|
prerelease: false
|
133
139
|
version_requirements: !ruby/object:Gem::Requirement
|
134
140
|
requirements:
|
135
141
|
- - "~>"
|
136
142
|
- !ruby/object:Gem::Version
|
137
|
-
version: '1
|
143
|
+
version: '1'
|
138
144
|
- - ">="
|
139
145
|
- !ruby/object:Gem::Version
|
140
|
-
version: 1.
|
146
|
+
version: 1.64.0
|
141
147
|
- !ruby/object:Gem::Dependency
|
142
148
|
name: aws-sdk-ses
|
143
149
|
requirement: !ruby/object:Gem::Requirement
|
144
150
|
requirements:
|
145
|
-
- - ">="
|
146
|
-
- !ruby/object:Gem::Version
|
147
|
-
version: 1.14.0
|
148
151
|
- - "~>"
|
149
152
|
- !ruby/object:Gem::Version
|
150
|
-
version: '1
|
153
|
+
version: '1'
|
154
|
+
- - ">="
|
155
|
+
- !ruby/object:Gem::Version
|
156
|
+
version: 1.29.0
|
151
157
|
type: :runtime
|
152
158
|
prerelease: false
|
153
159
|
version_requirements: !ruby/object:Gem::Requirement
|
154
160
|
requirements:
|
155
|
-
- - ">="
|
156
|
-
- !ruby/object:Gem::Version
|
157
|
-
version: 1.14.0
|
158
161
|
- - "~>"
|
159
162
|
- !ruby/object:Gem::Version
|
160
|
-
version: '1
|
163
|
+
version: '1'
|
164
|
+
- - ">="
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: 1.29.0
|
161
167
|
- !ruby/object:Gem::Dependency
|
162
168
|
name: dotenv
|
163
169
|
requirement: !ruby/object:Gem::Requirement
|
164
170
|
requirements:
|
165
171
|
- - ">="
|
166
172
|
- !ruby/object:Gem::Version
|
167
|
-
version: 2.
|
173
|
+
version: 2.7.0
|
168
174
|
- - "~>"
|
169
175
|
- !ruby/object:Gem::Version
|
170
|
-
version: '2.
|
176
|
+
version: '2.7'
|
171
177
|
type: :runtime
|
172
178
|
prerelease: false
|
173
179
|
version_requirements: !ruby/object:Gem::Requirement
|
174
180
|
requirements:
|
175
181
|
- - ">="
|
176
182
|
- !ruby/object:Gem::Version
|
177
|
-
version: 2.
|
183
|
+
version: 2.7.0
|
178
184
|
- - "~>"
|
179
185
|
- !ruby/object:Gem::Version
|
180
|
-
version: '2.
|
186
|
+
version: '2.7'
|
181
187
|
- !ruby/object:Gem::Dependency
|
182
188
|
name: net-sftp
|
183
189
|
requirement: !ruby/object:Gem::Requirement
|
@@ -247,9 +253,6 @@ files:
|
|
247
253
|
- lib/eco/api/common/session/sftp.rb
|
248
254
|
- lib/eco/api/common/version_patches.rb
|
249
255
|
- lib/eco/api/common/version_patches/ecoportal_api.rb
|
250
|
-
- lib/eco/api/common/version_patches/ecoportal_api/account_preferences.rb
|
251
|
-
- lib/eco/api/common/version_patches/ecoportal_api/base_model.rb
|
252
|
-
- lib/eco/api/common/version_patches/ecoportal_api/external_people.rb
|
253
256
|
- lib/eco/api/common/version_patches/ecoportal_api/external_person.rb
|
254
257
|
- lib/eco/api/common/version_patches/ecoportal_api/internal_person.rb
|
255
258
|
- lib/eco/api/common/version_patches/exception.rb
|
@@ -1,51 +0,0 @@
|
|
1
|
-
module Ecoportal
|
2
|
-
module API
|
3
|
-
class Internal
|
4
|
-
class Preferences
|
5
|
-
[
|
6
|
-
:show_sidebar,
|
7
|
-
:show_shortcuts,
|
8
|
-
:show_coming_soon,
|
9
|
-
:show_recently_visited_forms,
|
10
|
-
:show_tasks,
|
11
|
-
].each do |field|
|
12
|
-
key = field.to_s
|
13
|
-
define_method(field) do
|
14
|
-
if doc.key?(key)
|
15
|
-
doc[key]
|
16
|
-
else
|
17
|
-
true
|
18
|
-
end
|
19
|
-
end
|
20
|
-
define_method("#{field}=") do |value|
|
21
|
-
doc[key] = !!value
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
[
|
26
|
-
:kiosk_enabled,
|
27
|
-
:kiosk_workflow_message,
|
28
|
-
:kiosk_create_button_label,
|
29
|
-
:kiosk_create_button_help,
|
30
|
-
:kiosk_return_button_label,
|
31
|
-
:kiosk_return_button_help,
|
32
|
-
:kiosk_dashboard_button_label,
|
33
|
-
:kiosk_dashboard_button_help
|
34
|
-
].each do |field|
|
35
|
-
key = field.to_s
|
36
|
-
define_method(field) do
|
37
|
-
if doc.key?(key)
|
38
|
-
doc[key]
|
39
|
-
else
|
40
|
-
nil
|
41
|
-
end
|
42
|
-
end
|
43
|
-
define_method("#{field}=") do |value|
|
44
|
-
doc[key] = !!value
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
module Ecoportal
|
2
|
-
module API
|
3
|
-
module Common
|
4
|
-
class BaseModel
|
5
|
-
|
6
|
-
attr_reader :initial_doc
|
7
|
-
|
8
|
-
def initialize(doc = {}, parent: self, key: nil)
|
9
|
-
@_parent = parent
|
10
|
-
@_key = key
|
11
|
-
if !_parent || !_key
|
12
|
-
@doc = doc
|
13
|
-
@original_doc = JSON.parse(@doc.to_json)
|
14
|
-
@initial_doc = JSON.parse(@doc.to_json)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
def initial_doc
|
19
|
-
raise UnlinkedModel.new unless linked?
|
20
|
-
return @initial_doc if is_root?
|
21
|
-
_parent.initial_doc.dig(*[_key].flatten)
|
22
|
-
end
|
23
|
-
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
@@ -1,38 +0,0 @@
|
|
1
|
-
module Ecoportal
|
2
|
-
module API
|
3
|
-
class V1
|
4
|
-
class People
|
5
|
-
|
6
|
-
def job
|
7
|
-
operation = Common::BatchOperation.new("/people", person_class, logger: client.logger)
|
8
|
-
yield operation
|
9
|
-
# The batch operation is responsible for logging the output
|
10
|
-
job_id = create_job(operation)
|
11
|
-
status = wait_for_job_completion(job_id)
|
12
|
-
|
13
|
-
if status&.complete?
|
14
|
-
operation.process_response job_result(job_id, operation)
|
15
|
-
else
|
16
|
-
raise "Job `#{job_id}` not complete. Probably timeout after #{JOB_TIMEOUT + 120} seconds. Current status: #{status}"
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
private
|
21
|
-
|
22
|
-
def wait_for_job_completion(job_id)
|
23
|
-
# timeout library is evil. So we make poor-man timeout.
|
24
|
-
# https://jvns.ca/blog/2015/11/27/why-rubys-timeout-is-dangerous-and-thread-dot-raise-is-terrifying/
|
25
|
-
before = Time.now
|
26
|
-
while true
|
27
|
-
status = job_status(job_id)
|
28
|
-
break status if status.complete?
|
29
|
-
break status if Time.now >= before + (JOB_TIMEOUT + 120)
|
30
|
-
sleep(DELAY_STATUS_CHECK)
|
31
|
-
status
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|