ecoportal-api-v2 0.8.21 → 0.8.25
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +29 -1
- data/lib/ecoportal/api/common/content/hash_diff_patch.rb +1 -0
- data/lib/ecoportal/api/v2/page/component/reference_field.rb +8 -0
- data/lib/ecoportal/api/v2/page/section.rb +2 -3
- data/lib/ecoportal/api/v2/page.rb +1 -1
- data/lib/ecoportal/api/v2/pages.rb +1 -1
- data/lib/ecoportal/api/v2/registers.rb +52 -19
- data/lib/ecoportal/api/v2_version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6d0fd873fa135b382e7a8e272ab0bbdee729e6d15ebaceea8b4699fb3af650f2
|
4
|
+
data.tar.gz: 55e54d6e2b07d8108f2ca1a915118133ca6d4180519e6c8cafb7eacc449c60b0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 907b384d0f7f31fc9f1d656c7e535c814ac7bbe4d0d8034d7c80f924b3896f4cc8855296e871fa0f1c9d4dc4cff12e05bbedd893c4750dc9d34d02d355678531
|
7
|
+
data.tar.gz: 9ca8fc0aaf31e37dfd61abdc45e42269abacbb3220b6dcc5fa020a26f5f3e1096dbb2723ed23d8036281db86453c2a187f026877f98e94324a614daa23ae10c2
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,34 @@
|
|
1
1
|
# Change Log
|
2
2
|
All notable changes to this project will be documented in this file.
|
3
3
|
|
4
|
+
## [0.8.25] - 2022-02-04
|
5
|
+
|
6
|
+
### Added
|
7
|
+
- `Ecoportal::API::V2::Page::Component::ReferenceField#add` to add new references
|
8
|
+
|
9
|
+
### Changed
|
10
|
+
- `Ecoportal::API::Common::Content::HashDiffPatch#patch_data`
|
11
|
+
- Added support for model objects with no `patch_ver` (so diffs are calculated as well)
|
12
|
+
|
13
|
+
### Fixed
|
14
|
+
|
15
|
+
## [0.8.24] - 2022-01-05
|
16
|
+
|
17
|
+
### Fixed
|
18
|
+
- `Ecoportal::API::V2::Page#stages?` do not generate an object to this purpose
|
19
|
+
- `Ecoportal::API::V2::Registers#search` fix typo in print feedback
|
20
|
+
|
21
|
+
## [0.8.23] - 2021-12-24
|
22
|
+
|
23
|
+
### Added
|
24
|
+
- `Ecoportal::API::V2::Registers#search` added more feedback on what is going on
|
25
|
+
|
26
|
+
## [0.8.22] - 2021-12-23
|
27
|
+
|
28
|
+
### Fixed
|
29
|
+
- `Ecoportal::API::V2::Page::Section#add_component` was not using correctly `before` and `after`
|
30
|
+
- It was not correctly translating them into the existing component
|
31
|
+
|
4
32
|
## [0.8.21] - 2021-12-15
|
5
33
|
|
6
34
|
### Added
|
@@ -11,7 +39,7 @@ All notable changes to this project will be documented in this file.
|
|
11
39
|
|
12
40
|
### Changed
|
13
41
|
- Re-exposed `Ecoportal::API::V2::Stages#ordered`
|
14
|
-
|
42
|
+
|
15
43
|
### Fixed
|
16
44
|
- `Ecoportal::API::V2::Page::Component::ImagesField#images` typo in `klass`
|
17
45
|
|
@@ -137,7 +137,7 @@ module Ecoportal
|
|
137
137
|
if before
|
138
138
|
before_fld = to_component(before, side: side)
|
139
139
|
elsif after
|
140
|
-
after_fld = to_component(
|
140
|
+
after_fld = to_component(after, side: side)
|
141
141
|
end
|
142
142
|
|
143
143
|
if split?
|
@@ -145,7 +145,6 @@ module Ecoportal
|
|
145
145
|
else
|
146
146
|
ids_ary = component_ids
|
147
147
|
end
|
148
|
-
|
149
148
|
ids_ary.insert_one(field.id, before: before_fld&.id, after: after_fld&.id)
|
150
149
|
self
|
151
150
|
end
|
@@ -168,7 +167,7 @@ module Ecoportal
|
|
168
167
|
|
169
168
|
fields.find do |fld|
|
170
169
|
found = nil
|
171
|
-
found ||=
|
170
|
+
found ||= fld.id == value.id if value.is_a?(Ecoportal::API::V2::Page::Component)
|
172
171
|
found ||= fld.id == value
|
173
172
|
found ||= same_string?(fld.label, value)
|
174
173
|
end
|
@@ -49,7 +49,7 @@ module Ecoportal
|
|
49
49
|
# Requests to update an existing page via api.
|
50
50
|
# @note It won't launch the update unless there are changes
|
51
51
|
# @param doc [Hash, Page] data that at least contains an `id` (internal or external) of the target page.
|
52
|
-
# @return [Response] an object with the api response.
|
52
|
+
# @return [Ecoportal::API::Common::Response] an object with the api response.
|
53
53
|
def update(doc)
|
54
54
|
body = get_body(doc) # , level: "page"
|
55
55
|
# Launch only if there are changes
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'base64'
|
1
2
|
module Ecoportal
|
2
3
|
module API
|
3
4
|
class V2
|
@@ -42,18 +43,7 @@ module Ecoportal
|
|
42
43
|
# @return [Ecoportal::API::V2::Registers, Ecoportal::API::V2::Registers::SearchResults]
|
43
44
|
def search(register_id, options = {})
|
44
45
|
only_first = options.delete(:only_first)
|
45
|
-
|
46
|
-
# or a filter array (copy/paste from dev tools in the browser)
|
47
|
-
options = {query: nil, filters: []}.update(options)
|
48
|
-
options = {}.tap do |ret|
|
49
|
-
options.each do |key, value|
|
50
|
-
if key == :filters && value.any?
|
51
|
-
ret[key] = {filters: value}.to_json
|
52
|
-
else
|
53
|
-
ret[key] = value if key
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
46
|
+
options = build_options(options)
|
57
47
|
|
58
48
|
if only_first
|
59
49
|
response = client.get("/registers/#{register_id}/search", params: options)
|
@@ -62,19 +52,23 @@ module Ecoportal
|
|
62
52
|
end
|
63
53
|
|
64
54
|
cursor_id = nil
|
65
|
-
results = 0
|
55
|
+
results = 0; total = nil
|
66
56
|
loop do
|
67
57
|
options.update(cursor_id: cursor_id) if cursor_id
|
68
58
|
response = client.get("/registers/#{register_id}/search", params: options)
|
69
59
|
raise "Request failed - Status #{response.status}: #{response.body}" unless response.success?
|
70
60
|
|
71
|
-
data
|
72
|
-
|
61
|
+
data = response.body["data"]
|
62
|
+
total ||= data["total"]
|
63
|
+
if total != data["total"]
|
64
|
+
msg = "Change of total in search results. Probably due to changes that affect the filter (register: #{register_id}):"
|
65
|
+
print_search_status(msg, total, results, cursor_id, data, options)
|
66
|
+
#total = data["total"]
|
67
|
+
end
|
68
|
+
|
69
|
+
unless total == 0
|
73
70
|
results += data["results"].length
|
74
|
-
|
75
|
-
msg = "Registers SEARCH"
|
76
|
-
print "#{msg}: #{percent.round}% (of #{total})\r"
|
77
|
-
$stdout.flush
|
71
|
+
print_progress(results, total)
|
78
72
|
end
|
79
73
|
|
80
74
|
data["results"].each do |result|
|
@@ -83,12 +77,51 @@ module Ecoportal
|
|
83
77
|
end
|
84
78
|
|
85
79
|
break if total <= results
|
80
|
+
unless data["cursor_id"]
|
81
|
+
msg = "Possible error... finishing search for lack of cursor_id in response:"
|
82
|
+
print_search_status(msg, total, results, cursor_id, data, options)
|
83
|
+
end
|
86
84
|
break unless (cursor_id = data["cursor_id"])
|
87
85
|
end
|
88
86
|
self
|
89
87
|
end
|
90
88
|
|
89
|
+
private
|
90
|
+
|
91
|
+
def build_options(options)
|
92
|
+
# supply a query string
|
93
|
+
# or a filter array (copy/paste from dev tools in the browser)
|
94
|
+
options = {query: nil, filters: []}.update(options)
|
95
|
+
{}.tap do |ret|
|
96
|
+
options.each do |key, value|
|
97
|
+
if key == :filters && value.any?
|
98
|
+
ret[key] = {filters: value}.to_json
|
99
|
+
else
|
100
|
+
ret[key] = value if key
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
def print_search_status(msg, total, results, cursor_id, data, options)
|
107
|
+
msg += "\n"
|
108
|
+
msg += " • Original total: #{total}\n"
|
109
|
+
msg += " • Current total: #{data&.dig("total")}\n"
|
110
|
+
msg += " • Total results retrieved: #{results}\n"
|
111
|
+
msg += " • Cursor id: #{cursor_id} (#{Base64.decode64(cursor_id)})\n"
|
112
|
+
msg += " • Current cursor results: #{data["results"]&.length}\n"
|
113
|
+
msg += " • Next id: #{data["cursor_id"]} (#{Base64.decode64(data["cursor_id"])})\n" if data["cursor_id"]
|
114
|
+
msg += " • Options:"
|
115
|
+
puts msg
|
116
|
+
pp options
|
117
|
+
end
|
91
118
|
|
119
|
+
def print_progress(results, total)
|
120
|
+
percent = results * 100 / total
|
121
|
+
msg = "Registers SEARCH"
|
122
|
+
print "#{msg}: #{percent.round}% (of #{total})\r"
|
123
|
+
$stdout.flush
|
124
|
+
end
|
92
125
|
end
|
93
126
|
end
|
94
127
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ecoportal-api-v2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.25
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Oscar Segura
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-02-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|