apidae 0.2.9 → 0.3.0
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/app/models/apidae/file_import.rb +1 -0
- data/app/models/apidae/object.rb +53 -10
- data/app/models/apidae/selection.rb +20 -4
- data/app/models/apidae/town.rb +1 -1
- data/app/views/apidae/dashboard/index.html.erb +7 -3
- data/config/initializers/cache.rb +1 -0
- data/config/locales/apidae.fr.yml +7 -0
- data/db/migrate/20180314093512_add_tags_data_to_apidae_objects.rb +5 -0
- data/db/migrate/20180314132631_add_meta_data_to_apidae_objects.rb +5 -0
- data/lib/apidae/version.rb +1 -1
- data/test/dummy/db/schema.rb +2 -1
- data/test/dummy/log/development.log +12 -0
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c31e50b18e7ff1d211b61703728b267bf388649c
|
4
|
+
data.tar.gz: d33de8c1b3d227c5f133811446645f9715427347
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 16f8ae25874db45da9f5739846db146b74d27f05f6ff9346a0deee3f54fed5329ad6a7597c01ec59c7b128b17f7d902ec1d71aa227308048872a05c2e81b7740
|
7
|
+
data.tar.gz: cd4e15709a33f4de68a004c1a3baf6ba040efe676481e182c4b2dc3709ad9865c95b79c9acfe69595e2b89b72c8fe3e1541d7a083c236f66042e0956b04fae75
|
data/app/models/apidae/object.rb
CHANGED
@@ -8,13 +8,14 @@ module Apidae
|
|
8
8
|
|
9
9
|
store_accessor :pictures_data, :pictures
|
10
10
|
store_accessor :attachments_data, :attachments
|
11
|
-
store_accessor :type_data, :categories, :themes, :
|
11
|
+
store_accessor :type_data, :categories, :themes, :capacity, :classification, :labels, :chains
|
12
12
|
store_accessor :entity_data, :entity_id, :entity_name
|
13
13
|
store_accessor :contact, :telephone, :email, :website
|
14
14
|
store_accessor :address, :address_fields
|
15
15
|
store_accessor :openings_data, :openings_desc, :openings
|
16
16
|
store_accessor :rates_data, :rates_desc, :rates, :payment_methods
|
17
|
-
store_accessor :service_data, :services, :
|
17
|
+
store_accessor :service_data, :services, :equipments, :comfort, :activities
|
18
|
+
store_accessor :tags_data, :tags
|
18
19
|
|
19
20
|
ACT = 'ACTIVITE'
|
20
21
|
COS = 'COMMERCE_ET_SERVICE'
|
@@ -76,11 +77,13 @@ module Apidae
|
|
76
77
|
apidae_obj.openings_data = parse_openings(object_data[:ouverture])
|
77
78
|
apidae_obj.rates_data = parse_rates(object_data[:descriptionTarif])
|
78
79
|
apidae_obj.reservation = parse_reservation(object_data[:reservation])
|
79
|
-
apidae_obj.type_data = object_data[type_fields[:node]]
|
80
|
+
apidae_obj.type_data = parse_type_data(object_data[type_fields[:node]], object_data[:prestations])
|
80
81
|
apidae_obj.pictures_data = pictures_urls(object_data[:illustrations])
|
81
|
-
apidae_obj.attachments_data = attachments_urls(object_data[:
|
82
|
+
apidae_obj.attachments_data = attachments_urls(object_data[:multimedias])
|
82
83
|
apidae_obj.entity_data = entity_fields(object_data[:informations])
|
83
|
-
apidae_obj.service_data = object_data[:prestations]
|
84
|
+
apidae_obj.service_data = parse_service_data(object_data[:prestations], object_data[type_fields[:node]])
|
85
|
+
apidae_obj.tags_data = parse_tags_data(object_data[:presentation], object_data[:criteresInternes])
|
86
|
+
apidae_obj.meta_data = object_data[:metadonnees]
|
84
87
|
apidae_obj.save!
|
85
88
|
end
|
86
89
|
|
@@ -172,6 +175,42 @@ module Apidae
|
|
172
175
|
end
|
173
176
|
end
|
174
177
|
|
178
|
+
def self.parse_type_data(data_hash, prestations_hash)
|
179
|
+
if data_hash
|
180
|
+
{
|
181
|
+
categories: lists_ids(data_hash[:categories]),
|
182
|
+
themes: lists_ids(data_hash[:themes]),
|
183
|
+
capacity: data_hash[:capacite],
|
184
|
+
classification: nodes_ids(data_hash[:classement], data_hash[:classementPrefectoral]),
|
185
|
+
labels: lists_ids(data_hash[:labels], prestations_hash[:labelsTourismeHandicap]),
|
186
|
+
chains: lists_ids(data_hash[:chaines]) + nodes_ids(data_hash[:chaineEtLabel]),
|
187
|
+
activities: lists_ids(data_hash[:activites])
|
188
|
+
}
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
def self.parse_service_data(data_hash, type_data_hash)
|
193
|
+
if data_hash
|
194
|
+
{
|
195
|
+
services: lists_ids(data_hash[:services]),
|
196
|
+
equipments: lists_ids(data_hash[:equipements]),
|
197
|
+
comfort: lists_ids(data_hash[:conforts]),
|
198
|
+
activities: lists_ids(data_hash[:activites]) + lists_ids(data_hash[:activites])
|
199
|
+
}
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
203
|
+
def self.parse_tags_data(pres_data_hash, crit_data_hash)
|
204
|
+
tags = []
|
205
|
+
if pres_data_hash
|
206
|
+
tags += lists_ids(pres_data_hash[:typologiesPromoSitra])
|
207
|
+
end
|
208
|
+
unless crit_data_hash.blank?
|
209
|
+
tags += crit_data_hash.map {|c| c[:id]}
|
210
|
+
end
|
211
|
+
{tags: tags}
|
212
|
+
end
|
213
|
+
|
175
214
|
def self.parse_reservation(reservation_hash)
|
176
215
|
if reservation_hash
|
177
216
|
if reservation_hash[:complement]
|
@@ -218,11 +257,15 @@ module Apidae
|
|
218
257
|
end
|
219
258
|
|
220
259
|
def self.node_id(node, key)
|
221
|
-
if node && node[key]
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
260
|
+
node[key][:id] if node && node[key]
|
261
|
+
end
|
262
|
+
|
263
|
+
def self.lists_ids(*lists)
|
264
|
+
lists.blank? ? [] : lists.map {|l| l.blank? ? [] : l.map {|elt| elt[:id]}}.flatten.uniq
|
265
|
+
end
|
266
|
+
|
267
|
+
def self.nodes_ids(*nodes)
|
268
|
+
nodes.blank? ? [] : nodes.select {|n| !n.blank?}.map {|n| n[:id]}
|
226
269
|
end
|
227
270
|
end
|
228
271
|
end
|
@@ -40,13 +40,25 @@ module Apidae
|
|
40
40
|
end
|
41
41
|
|
42
42
|
def api_results(opts = {})
|
43
|
-
|
44
|
-
|
43
|
+
key = cache_key(:results)
|
44
|
+
res = $apidae_cache.read(key)
|
45
|
+
unless res
|
46
|
+
query_args = build_args(SELECTION_ENDPOINT, opts.merge({selection_ids: [apidae_id]}))
|
47
|
+
res = query_api(query_args, true)
|
48
|
+
$apidae_cache.write(key, res)
|
49
|
+
end
|
50
|
+
res
|
45
51
|
end
|
46
52
|
|
47
53
|
def api_agenda(from, to)
|
48
|
-
|
49
|
-
|
54
|
+
key = cache_key(:agenda, from, to)
|
55
|
+
res = $apidae_cache.read(key)
|
56
|
+
unless res
|
57
|
+
query_args = build_args(AGENDA_ENDPOINT, {selection_ids: [apidae_id], from: from, to: to})
|
58
|
+
res = query_api(query_args, true)
|
59
|
+
$apidae_cache.write(key, res)
|
60
|
+
end
|
61
|
+
res
|
50
62
|
end
|
51
63
|
|
52
64
|
private
|
@@ -131,5 +143,9 @@ module Apidae
|
|
131
143
|
def generate_reference
|
132
144
|
self.reference ||= (self.label.parameterize || self.apidae_id)
|
133
145
|
end
|
146
|
+
|
147
|
+
def cache_key(*args)
|
148
|
+
"#{apidae_id}_#{args.map {|a| a.to_s.parameterize}.join('_')}"
|
149
|
+
end
|
134
150
|
end
|
135
151
|
end
|
data/app/models/apidae/town.rb
CHANGED
@@ -3,7 +3,7 @@ module Apidae
|
|
3
3
|
def self.import(towns_json)
|
4
4
|
towns_hashes = JSON.parse(towns_json, symbolize_names: true)
|
5
5
|
if towns_hashes.length != count
|
6
|
-
countries = Hash[Reference.where(apidae_type: "Pays").map {|ref| [ref.
|
6
|
+
countries = Hash[Reference.where(apidae_type: "Pays").map {|ref| [ref.apidae_id, ref.label(:fr)]}]
|
7
7
|
towns_hashes.each do |town_data|
|
8
8
|
town = Town.find_or_initialize_by(apidae_id: town_data[:id])
|
9
9
|
town.name = town_data[:nom]
|
@@ -10,7 +10,9 @@
|
|
10
10
|
<thead class="<%= styles[:table_head] %>">
|
11
11
|
<tr>
|
12
12
|
<th>Date</th>
|
13
|
-
<th>
|
13
|
+
<th>Créations</th>
|
14
|
+
<th>Mises à jour</th>
|
15
|
+
<th>Suppressions</th>
|
14
16
|
<th>Statut</th>
|
15
17
|
</tr>
|
16
18
|
</thead>
|
@@ -18,8 +20,10 @@
|
|
18
20
|
<% @last_imports.each do |import| %>
|
19
21
|
<tr>
|
20
22
|
<td><%= import.updated_at.strftime('Le %d/%m/%Y à %H:%M') if import.updated_at %></td>
|
21
|
-
<td><%= import.
|
22
|
-
<td><%= import.
|
23
|
+
<td><%= import.created %></td>
|
24
|
+
<td><%= import.updated %></td>
|
25
|
+
<td><%= import.deleted %></td>
|
26
|
+
<td><%= t "apidae.file_import.status.#{import.status}" %></td>
|
23
27
|
</tr>
|
24
28
|
<% end %>
|
25
29
|
<% if @last_imports.empty? %>
|
@@ -0,0 +1 @@
|
|
1
|
+
$apidae_cache = ActiveSupport::Cache::FileStore.new('cache/apidae', expires_in: 24.hours)
|
data/lib/apidae/version.rb
CHANGED
data/test/dummy/db/schema.rb
CHANGED
@@ -10,7 +10,7 @@
|
|
10
10
|
#
|
11
11
|
# It's strongly recommended that you check this file into your version control system.
|
12
12
|
|
13
|
-
ActiveRecord::Schema.define(version:
|
13
|
+
ActiveRecord::Schema.define(version: 20180314093512) do
|
14
14
|
|
15
15
|
# These are extensions that must be enabled in order to support this database
|
16
16
|
enable_extension "plpgsql"
|
@@ -72,6 +72,7 @@ ActiveRecord::Schema.define(version: 20180307170349) do
|
|
72
72
|
t.jsonb "service_data"
|
73
73
|
t.jsonb "rates_data"
|
74
74
|
t.jsonb "attachments_data"
|
75
|
+
t.jsonb "tags_data"
|
75
76
|
end
|
76
77
|
|
77
78
|
create_table "apidae_objects_selections", id: :serial, force: :cascade do |t|
|
@@ -332,3 +332,15 @@ Migrating to CreateApidaeReferences (20180307170349)
|
|
332
332
|
[1m[35m (0.1ms)[0m [1m[35mCOMMIT[0m
|
333
333
|
[1m[35m (0.2ms)[0m [1m[34mSELECT pg_advisory_unlock(6140174353533887940)[0m
|
334
334
|
[1m[35m (0.2ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
335
|
+
[1m[35m (0.2ms)[0m [1m[34mSELECT pg_try_advisory_lock(6140174353533887940)[0m
|
336
|
+
[1m[35m (2.1ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
337
|
+
Migrating to AddTagsDataToApidaeObjects (20180314093512)
|
338
|
+
[1m[35m (0.2ms)[0m [1m[35mBEGIN[0m
|
339
|
+
[1m[35m (2.6ms)[0m [1m[35mALTER TABLE "apidae_objects" ADD "tags_data" jsonb[0m
|
340
|
+
[1m[35mSQL (0.3ms)[0m [1m[32mINSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version"[0m [["version", "20180314093512"]]
|
341
|
+
[1m[35m (1.1ms)[0m [1m[35mCOMMIT[0m
|
342
|
+
[1m[36mActiveRecord::InternalMetadata Load (1.3ms)[0m [1m[34mSELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2[0m [["key", "environment"], ["LIMIT", 1]]
|
343
|
+
[1m[35m (0.1ms)[0m [1m[35mBEGIN[0m
|
344
|
+
[1m[35m (0.1ms)[0m [1m[35mCOMMIT[0m
|
345
|
+
[1m[35m (0.2ms)[0m [1m[34mSELECT pg_advisory_unlock(6140174353533887940)[0m
|
346
|
+
[1m[35m (0.2ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: apidae
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jean-Baptiste Vilain
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-03-
|
11
|
+
date: 2018-03-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -113,6 +113,8 @@ files:
|
|
113
113
|
- app/views/apidae/selections/new.html.erb
|
114
114
|
- app/views/apidae/selections/show.html.erb
|
115
115
|
- app/views/layouts/apidae/application.html.erb
|
116
|
+
- config/initializers/cache.rb
|
117
|
+
- config/locales/apidae.fr.yml
|
116
118
|
- config/routes.rb
|
117
119
|
- db/migrate/20170512212941_create_apidae_selections.rb
|
118
120
|
- db/migrate/20170512214641_create_apidae_objects.rb
|
@@ -132,6 +134,8 @@ files:
|
|
132
134
|
- db/migrate/20180222105302_rename_openings_to_openings_data.rb
|
133
135
|
- db/migrate/20180307164936_add_attachments_data_to_apidae_objects.rb
|
134
136
|
- db/migrate/20180307170349_create_apidae_references.rb
|
137
|
+
- db/migrate/20180314093512_add_tags_data_to_apidae_objects.rb
|
138
|
+
- db/migrate/20180314132631_add_meta_data_to_apidae_objects.rb
|
135
139
|
- lib/apidae.rb
|
136
140
|
- lib/apidae/engine.rb
|
137
141
|
- lib/apidae/version.rb
|