apidae 1.3.3 → 1.3.7
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 +5 -5
- data/app/models/apidae/apidae_data_parser.rb +34 -11
- data/app/models/apidae/file_import.rb +15 -6
- data/app/models/apidae/obj.rb +20 -12
- data/app/models/apidae/project.rb +6 -0
- data/app/models/apidae/selection.rb +14 -0
- data/app/models/apidae/territory.rb +1 -1
- data/config/initializers/constants.rb +5 -2
- data/lib/apidae/version.rb +1 -1
- data/test/data/shared_selections.json +15 -0
- data/test/dummy/app/assets/config/manifest.js +1 -0
- data/test/dummy/db/schema.rb +15 -6
- data/test/dummy/log/development.log +24 -69
- data/test/models/apidae/file_import_test.rb +23 -0
- metadata +7 -6
- data/test/dummy/log/test.log +0 -3398
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 75dde9650200cc683aac33972e62266dd313530eb14fdf1adce960666b055752
|
|
4
|
+
data.tar.gz: 210f1dcc7a842812d00fb4ea471b33c2f00327b4ae32bb1727dc831e878df263
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f1e8f20bd1163222ad25c737b2d4593159c774f15afe9d10143317540de6fb4cab3f66f09bab4155e41e7459b7728e3bb64ba39f46600011fd1bc7daac561eaa
|
|
7
|
+
data.tar.gz: 44ca9a17ccd7d50fe8bf878158902f623e007162027abc923293dbbf3ee96e0fde3b41809f1d93b8e33f8000ff85acc68d40d3c1c4c9025db2bcf093caabb815
|
|
@@ -113,7 +113,7 @@ module Apidae
|
|
|
113
113
|
short_desc: node_value(data_hash, :descriptifCourt, *locales),
|
|
114
114
|
long_desc: node_value(data_hash, :descriptifDetaille, *locales),
|
|
115
115
|
theme_desc: data_hash[:descriptifsThematises].blank? ? {} : Hash[data_hash[:descriptifsThematises].map {|th| [node_id(th, :theme), node_value(th, :description, *locales)]}],
|
|
116
|
-
private_desc: private_data.blank? ? {} : Hash[private_data.map {|d| [d[:nomTechnique], node_value(d, :descriptif, *locales)]}]
|
|
116
|
+
private_desc: private_data.blank? ? {} : Hash[private_data.map {|d| [d[:nomTechnique], (node_value(d, :descriptif, *locales).blank? ? {LOCALE_FR => d[:libelleFr]} : node_value(d, :descriptif, *locales))]}]
|
|
117
117
|
}
|
|
118
118
|
end
|
|
119
119
|
end
|
|
@@ -151,6 +151,7 @@ module Apidae
|
|
|
151
151
|
name: localized_value(att, :nom, locale),
|
|
152
152
|
url: att[:traductionFichiers][0][:url].gsub('http:', 'https:'),
|
|
153
153
|
type: att[:type],
|
|
154
|
+
link: att[:link],
|
|
154
155
|
description: localized_value(att, :legende, locale)
|
|
155
156
|
}
|
|
156
157
|
end
|
|
@@ -222,6 +223,8 @@ module Apidae
|
|
|
222
223
|
loc_data[:latitude] = geoloc_details[:geoJson][:coordinates][1]
|
|
223
224
|
loc_data[:longitude] = geoloc_details[:geoJson][:coordinates][0]
|
|
224
225
|
end
|
|
226
|
+
loc_data[:map_reference] = geoloc_details[:reperePlan]
|
|
227
|
+
loc_data[:altitude] = geoloc_details[:altitude] if geoloc_details
|
|
225
228
|
loc_data[:access] = node_value(geoloc_details, :complement) if geoloc_details
|
|
226
229
|
loc_data[:environments] = location_hash[:environnements].map {|e| e[:id]} if location_hash[:environnements]
|
|
227
230
|
end
|
|
@@ -236,6 +239,7 @@ module Apidae
|
|
|
236
239
|
openings_desc: node_value(openings_hash, :periodeEnClair, *locales),
|
|
237
240
|
openings_desc_mode: openings_hash[:periodeEnClairGenerationMode] == 'AUTOMATIQUE' ? MODE_AUTO : MODE_MANUAL,
|
|
238
241
|
openings: build_openings(openings_hash, *locales),
|
|
242
|
+
all_year_long: openings_hash[:ouvertTouteLAnnee] == 'OUVERT_TOUTE_L_ANNEE' ? 'true' : 'false',
|
|
239
243
|
time_periods: lists_ids(openings_hash[:indicationsPeriode]),
|
|
240
244
|
openings_extra: lists_ids(openings_hash[:ouverturesComplementaires])
|
|
241
245
|
}
|
|
@@ -249,6 +253,7 @@ module Apidae
|
|
|
249
253
|
methods = rates_hash[:modesPaiement].blank? ? [] : rates_hash[:modesPaiement].map {|p| p[:id]}
|
|
250
254
|
{
|
|
251
255
|
rates_desc: desc, rates: values, payment_methods: methods,
|
|
256
|
+
tax_included: rates_hash[:taxeDeSejourIncluse].blank? ? nil : (rates_hash[:taxeDeSejourIncluse] == 'OUI'),
|
|
252
257
|
rates_desc_mode: rates_hash[:tarifsEnClairGenerationMode] == 'AUTOMATIQUE' ? MODE_AUTO : MODE_MANUAL,
|
|
253
258
|
includes: node_value(rates_hash, :leTarifComprend, *locales),
|
|
254
259
|
excludes: node_value(rates_hash, :leTarifNeComprendPas, *locales),
|
|
@@ -264,18 +269,21 @@ module Apidae
|
|
|
264
269
|
apidae_obj.apidae_subtype = node_id(data_hash, :rubrique) if apidae_obj.apidae_type == Obj::EQU
|
|
265
270
|
apidae_obj.apidae_subtype = lists_ids(data_hash[:typesHebergement]).first if apidae_obj.apidae_type == Obj::SPA
|
|
266
271
|
{
|
|
267
|
-
categories: lists_ids(data_hash[:categories], data_hash[:typesDetailles], data_hash[:activiteCategories]),
|
|
272
|
+
categories: lists_ids(data_hash[:categories], data_hash[:typesDetailles], data_hash[:activiteCategories], data_hash[:typesHabitation]),
|
|
268
273
|
themes: lists_ids(data_hash[:themes]),
|
|
269
274
|
capacity: (data_hash[:capacite] || {})
|
|
270
275
|
.merge(presta_hash ? {group_min: presta_hash[:tailleGroupeMin], group_max: presta_hash[:tailleGroupeMax],
|
|
271
276
|
age_min: presta_hash[:ageMin], age_max: presta_hash[:ageMax]} : {}),
|
|
272
277
|
classification: nodes_ids(data_hash[:classement], data_hash[:classementPrefectoral], data_hash[:classification]) +
|
|
273
278
|
lists_ids(data_hash[:classementsGuides]) + lists_ids(data_hash[:classements]),
|
|
279
|
+
classification_date: data_hash[:dateClassement],
|
|
280
|
+
classification_ref: data_hash[:numeroClassement],
|
|
274
281
|
labels: lists_ids(data_hash[:labels], data_hash[:labelsChartesQualite], prestations_hash[:labelsTourismeHandicap]) +
|
|
275
282
|
(node_id(data_hash, :typeLabel) ? [node_id(data_hash, :typeLabel)] : []),
|
|
276
283
|
chains: lists_ids(data_hash[:chaines]) + nodes_ids(data_hash[:chaineEtLabel]),
|
|
277
284
|
area: apidae_obj.apidae_type == Obj::DOS ? data_hash.except(:classification) : node_value(data_hash, :lieuDePratique),
|
|
278
|
-
track: apidae_obj.apidae_type == Obj::EQU ? data_hash[:itineraire] : nil,
|
|
285
|
+
track: apidae_obj.apidae_type == Obj::EQU ? (data_hash[:itineraire] || {}).except(:passagesDelicats) : nil,
|
|
286
|
+
tricky_sections: apidae_obj.apidae_type == Obj::EQU ? node_value(data_hash[:itineraire], :passagesDelicats, *locales) : nil,
|
|
279
287
|
products: lists_ids(data_hash[:typesProduit], data_hash[:aopAocIgps], data_hash[:specialites]),
|
|
280
288
|
audience: lists_ids(prestations_hash[:typesClientele]),
|
|
281
289
|
animals: {allowed: prestations_hash[:animauxAcceptes] == 'ACCEPTES', desc: node_value(prestations_hash, :descriptifAnimauxAcceptes, *locales),
|
|
@@ -283,7 +291,10 @@ module Apidae
|
|
|
283
291
|
extra: apidae_obj.apidae_type == Obj::SPA ? node_value(data_hash, :formuleHebergement, *locales) : node_value(prestations_hash, :complementAccueil, *locales),
|
|
284
292
|
duration: apidae_obj.apidae_type == Obj::SPA ? {days: data_hash[:nombreJours], nights: data_hash[:nombreNuits]} : data_hash[:dureeSeance],
|
|
285
293
|
certifications: data_hash[:agrements].blank? ? [] : data_hash[:agrements].map {|a| {id: a[:type][:id], identifier: a[:numero]}},
|
|
286
|
-
business: business_hash
|
|
294
|
+
business: (business_hash || {}).except(:sallesEquipeesPour, :sallesEquipement, :sallesRestauration, :sallesReunion, :sallesHebergement),
|
|
295
|
+
business_equipments: lists_ids((business_hash || {})[:sallesEquipeesPour], (business_hash || {})[:sallesEquipement],
|
|
296
|
+
(business_hash || {})[:sallesRestauration], (business_hash || {})[:sallesHebergement]),
|
|
297
|
+
business_rooms: (business_hash || {})[:sallesReunion]
|
|
287
298
|
}
|
|
288
299
|
end
|
|
289
300
|
|
|
@@ -317,13 +328,19 @@ module Apidae
|
|
|
317
328
|
tags
|
|
318
329
|
end
|
|
319
330
|
|
|
320
|
-
def self.parse_booking(reservation_hash, *locales)
|
|
331
|
+
def self.parse_booking(reservation_hash, visits_hash, *locales)
|
|
332
|
+
booking_hash = {}
|
|
321
333
|
if reservation_hash
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
334
|
+
booking_hash[:booking_desc] = node_value(reservation_hash, :complement, *locales),
|
|
335
|
+
booking_hash[:booking_entities] = reservation_hash[:organismes]
|
|
336
|
+
end
|
|
337
|
+
if visits_hash
|
|
338
|
+
booking_hash[:visits_allowed] = visits_hash[:visitable] == true
|
|
339
|
+
booking_hash[:visits_desc] = node_value(visits_hash, :complementVisite, *locales)
|
|
340
|
+
booking_hash[:visits_duration] = visits_hash[:dureeMoyenneVisiteIndividuelle]
|
|
341
|
+
booking_hash[:visits_services] = lists_ids(visits_hash[:prestationsVisitesGroupees]) + lists_ids(visits_hash[:prestationsVisitesIndividuelles])
|
|
326
342
|
end
|
|
343
|
+
booking_hash
|
|
327
344
|
end
|
|
328
345
|
|
|
329
346
|
def self.parse_town(location_hash)
|
|
@@ -337,8 +354,14 @@ module Apidae
|
|
|
337
354
|
|
|
338
355
|
def self.parse_entity_fields(information_hash, type_data_hash, sp_hash)
|
|
339
356
|
entity_hash = {}
|
|
340
|
-
if information_hash
|
|
341
|
-
|
|
357
|
+
if information_hash
|
|
358
|
+
if information_hash[:structureGestion]
|
|
359
|
+
entity_hash.merge!({entity_id: information_hash[:structureGestion][:id], service_provider_id: node_id(type_data_hash, :prestataireActivites)})
|
|
360
|
+
end
|
|
361
|
+
|
|
362
|
+
if information_hash[:informationsLegales]
|
|
363
|
+
entity_hash.merge!({legal: information_hash[:informationsLegales]})
|
|
364
|
+
end
|
|
342
365
|
end
|
|
343
366
|
if sp_hash && sp_hash[:prestataireActivites]
|
|
344
367
|
entity_hash[:is_service_provider] = true
|
|
@@ -30,18 +30,21 @@ module Apidae
|
|
|
30
30
|
Town.import(zfile.read(TOWNS_FILE))
|
|
31
31
|
logger.info "Completed #{Town.count} towns update"
|
|
32
32
|
end
|
|
33
|
-
zfile.each do |file|
|
|
33
|
+
ordered_files(zfile).each do |file|
|
|
34
34
|
if file.file? && file.name.end_with?('.json')
|
|
35
35
|
logger.info "Processing file : #{file.name}"
|
|
36
36
|
if file.name.include?(MODIFIED_DIR)
|
|
37
37
|
add_or_update_objects(zfile.read(file.name), result, project.locales, project.versions)
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
elsif file.name.include?(SELECTIONS_FILE)
|
|
38
|
+
end
|
|
39
|
+
if file.name.include?(SELECTIONS_FILE)
|
|
41
40
|
add_or_update_selections(project, zfile.read(file.name), result)
|
|
42
41
|
end
|
|
42
|
+
if file.name.include?(DELETED_FILE)
|
|
43
|
+
delete_objects(zfile.read(file.name), result)
|
|
44
|
+
end
|
|
43
45
|
end
|
|
44
46
|
end
|
|
47
|
+
project.cleanup_selections
|
|
45
48
|
create(result.except(:selections)
|
|
46
49
|
.merge({remote_file: (zip_file.is_a?(File) ? zip_file.path : zip_file), status: STATUS_COMPLETE, apidae_id: project_id}))
|
|
47
50
|
logger.info "Import results : #{result}"
|
|
@@ -104,12 +107,16 @@ module Apidae
|
|
|
104
107
|
end
|
|
105
108
|
end
|
|
106
109
|
|
|
110
|
+
def self.ordered_files(zfile)
|
|
111
|
+
zfile.sort_by {|f| f.name.include?(MODIFIED_DIR) ? 0 : (f.name.include?(SELECTIONS_FILE) ? 1 : 2)}
|
|
112
|
+
end
|
|
113
|
+
|
|
107
114
|
def self.delete_objects(deleted_json, result)
|
|
108
115
|
deleted_ids = JSON.parse(deleted_json)
|
|
109
116
|
deleted_ids.each do |id|
|
|
110
117
|
obj = Obj.find_by_apidae_id(id)
|
|
111
118
|
if obj
|
|
112
|
-
obj.destroy!
|
|
119
|
+
obj.destroy! if obj.selections.empty?
|
|
113
120
|
result[:deleted] += 1
|
|
114
121
|
else
|
|
115
122
|
logger.info "skipping object deletion : #{id}"
|
|
@@ -163,7 +170,9 @@ module Apidae
|
|
|
163
170
|
def self.add_or_update_selections(project, selections_json, result)
|
|
164
171
|
selections_hashes = JSON.parse(selections_json, symbolize_names: true)
|
|
165
172
|
deleted_ids = Selection.where(apidae_project_id: project.id).collect {|sel| sel.apidae_id}.uniq - selections_hashes.collect {|sel| sel[:id]}
|
|
166
|
-
Selection.where(apidae_id: deleted_ids).
|
|
173
|
+
apidae_selection_ids = Selection.where(apidae_id: deleted_ids).map {|s| s.id}
|
|
174
|
+
SelectionObject.where(apidae_selection_id: apidae_selection_ids).delete_all
|
|
175
|
+
Selection.where(id: apidae_selection_ids).delete_all
|
|
167
176
|
selections_hashes.each do |selection_data|
|
|
168
177
|
logger.info "Updating selection #{selection_data[:id]}"
|
|
169
178
|
Selection.add_or_update(selection_data, project.id)
|
data/app/models/apidae/obj.rb
CHANGED
|
@@ -7,22 +7,24 @@ module Apidae
|
|
|
7
7
|
|
|
8
8
|
attr_accessor :locale
|
|
9
9
|
attr_accessor :obj_version
|
|
10
|
+
attr_accessor :obj_versions
|
|
10
11
|
|
|
11
12
|
store_accessor :title_data, :title
|
|
12
13
|
store_accessor :owner_data, :owner_name, :owner_id
|
|
13
14
|
store_accessor :description_data, :short_desc, :long_desc, :theme_desc, :private_desc
|
|
14
15
|
store_accessor :pictures_data, :pictures
|
|
15
16
|
store_accessor :attachments_data, :attachments
|
|
16
|
-
store_accessor :type_data, :categories, :themes, :capacity, :classification, :
|
|
17
|
-
:
|
|
18
|
-
|
|
17
|
+
store_accessor :type_data, :categories, :themes, :capacity, :classification, :classification_date,
|
|
18
|
+
:classification_ref, :labels, :chains, :area, :track, :tricky_sections, :products, :audience, :animals,
|
|
19
|
+
:animals_desc, :extra, :duration, :certifications, :business, :business_equipments, :business_rooms
|
|
20
|
+
store_accessor :entity_data, :entity_id, :entity_name, :service_provider_id, :is_service_provider, :legal
|
|
19
21
|
store_accessor :contact_data, :telephone, :email, :website, :google, :facebook, :twitter, :yelp, :trip_advisor, :fax,
|
|
20
22
|
:mobile_website, :shorty_url, :contacts
|
|
21
|
-
store_accessor :location_data, :address, :place, :latitude, :longitude, :access, :territories, :environments
|
|
23
|
+
store_accessor :location_data, :address, :place, :latitude, :longitude, :access, :territories, :environments, :altitude, :map_reference
|
|
22
24
|
store_accessor :openings_data, :openings_desc, :openings_desc_mode, :openings, :time_periods, :openings_extra
|
|
23
|
-
store_accessor :rates_data, :rates_desc, :rates_desc_mode, :rates, :payment_methods, :includes, :excludes, :rates_extra
|
|
25
|
+
store_accessor :rates_data, :rates_desc, :rates_desc_mode, :rates, :payment_methods, :includes, :excludes, :rates_extra, :tax_included
|
|
24
26
|
store_accessor :service_data, :services, :equipments, :comfort, :activities, :challenged, :languages
|
|
25
|
-
store_accessor :booking_data, :booking_desc, :booking_entities
|
|
27
|
+
store_accessor :booking_data, :booking_desc, :booking_entities, :visits_allowed, :visits_desc, :visits_duration, :visits_services
|
|
26
28
|
store_accessor :tags_data, :promo, :internal, :linked
|
|
27
29
|
store_accessor :version_data, :versioned_fields
|
|
28
30
|
|
|
@@ -83,7 +85,7 @@ module Apidae
|
|
|
83
85
|
COS => {node: :informationsCommerceEtService, subtype: :commerceEtServiceType},
|
|
84
86
|
DEG => {node: :informationsDegustation, subtype: :degustationType},
|
|
85
87
|
DOS => {node: :informationsDomaineSkiable, subtype: :domaineSkiableType},
|
|
86
|
-
EQU => {node: :informationsEquipement, subtype: :
|
|
88
|
+
EQU => {node: :informationsEquipement, subtype: :rubrique},
|
|
87
89
|
FEM => {node: :informationsFeteEtManifestation, subtype: :feteEtManifestationType},
|
|
88
90
|
HCO => {node: :informationsHebergementCollectif, subtype: :hebergementCollectifType},
|
|
89
91
|
HLO => {node: :informationsHebergementLocatif, subtype: :hebergementLocatifType},
|
|
@@ -100,6 +102,7 @@ module Apidae
|
|
|
100
102
|
after_initialize do
|
|
101
103
|
@locale = DEFAULT_LOCALE
|
|
102
104
|
@obj_version = DEFAULT_VERSION
|
|
105
|
+
@obj_versions = {}
|
|
103
106
|
end
|
|
104
107
|
|
|
105
108
|
def root_obj
|
|
@@ -111,11 +114,15 @@ module Apidae
|
|
|
111
114
|
end
|
|
112
115
|
|
|
113
116
|
def in_version(v)
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
+
if v == DEFAULT_VERSION && root_obj_id.nil?
|
|
118
|
+
@obj_version = DEFAULT_VERSION
|
|
119
|
+
self
|
|
120
|
+
else
|
|
121
|
+
if @obj_versions[v].nil?
|
|
122
|
+
@obj_versions[v] = versions.where(version: v).first
|
|
123
|
+
end
|
|
124
|
+
@obj_versions[v]
|
|
117
125
|
end
|
|
118
|
-
@cached_versions[v]
|
|
119
126
|
end
|
|
120
127
|
|
|
121
128
|
def in_locale(l)
|
|
@@ -164,6 +171,7 @@ module Apidae
|
|
|
164
171
|
apidae_obj
|
|
165
172
|
end
|
|
166
173
|
|
|
174
|
+
# Note : overrides existing fields (not a merge)
|
|
167
175
|
def self.populate_fields(apidae_obj, object_data, locales)
|
|
168
176
|
type_fields = TYPES_DATA[object_data[:type]]
|
|
169
177
|
apidae_obj.last_update = DateTime.parse(object_data[:gestion][:dateModification]) unless object_data[:gestion].blank?
|
|
@@ -178,7 +186,7 @@ module Apidae
|
|
|
178
186
|
apidae_obj.town = ApidaeDataParser.parse_town(object_data[:localisation])
|
|
179
187
|
apidae_obj.openings_data = ApidaeDataParser.parse_openings(object_data[:ouverture], *locales)
|
|
180
188
|
apidae_obj.rates_data = ApidaeDataParser.parse_rates(object_data[:descriptionTarif], *locales)
|
|
181
|
-
apidae_obj.booking_data = ApidaeDataParser.parse_booking(object_data[:reservation], *locales)
|
|
189
|
+
apidae_obj.booking_data = ApidaeDataParser.parse_booking(object_data[:reservation], object_data[:visites], *locales)
|
|
182
190
|
apidae_obj.type_data = ApidaeDataParser.parse_type_data(apidae_obj, object_data[type_fields[:node]], object_data[:prestations],
|
|
183
191
|
object_data[:tourismeAffaires], *locales)
|
|
184
192
|
apidae_obj.pictures_data = ApidaeDataParser.parse_pictures_data(object_data[:illustrations], *locales)
|
|
@@ -42,6 +42,20 @@ module Apidae
|
|
|
42
42
|
SelectionObject.where(apidae_selection_id: apidae_sel.id, apidae_object_id: removed_ids).delete_all
|
|
43
43
|
end
|
|
44
44
|
|
|
45
|
+
def cleanup
|
|
46
|
+
obsolete_count = apidae_selection_objects
|
|
47
|
+
.joins("LEFT JOIN apidae_objs ON apidae_objs.id = apidae_selection_objects.apidae_object_id")
|
|
48
|
+
.where("apidae_objs.id IS NULL")
|
|
49
|
+
.delete_all
|
|
50
|
+
logger.info "Cleaned up #{obsolete_count} obsolete selection-objects associations for selection #{apidae_id}"
|
|
51
|
+
|
|
52
|
+
dups = apidae_selection_objects.reload.group(:apidae_object_id)
|
|
53
|
+
.select("COUNT(id), apidae_object_id, ARRAY_AGG(id) AS so_ids")
|
|
54
|
+
.having("COUNT(id) > ?", 1).map {|so| so.so_ids}
|
|
55
|
+
dups_count = apidae_selection_objects.where(id: dups.map {|d| d.sort[1..-1]}.flatten).delete_all
|
|
56
|
+
logger.info "Cleaned up #{dups_count} duplicate selection-objects associations for selection #{apidae_id}"
|
|
57
|
+
end
|
|
58
|
+
|
|
45
59
|
def results(where_clause, offset, size)
|
|
46
60
|
objects.includes(:town).limit(size).offset(offset).where(where_clause)
|
|
47
61
|
end
|
|
@@ -27,6 +27,9 @@ module Apidae
|
|
|
27
27
|
|
|
28
28
|
LOCALIZED_FIELDS = [:title, :short_desc, :long_desc, :pictures, :attachments, :openings_desc, :rates_desc,
|
|
29
29
|
:includes, :excludes, :extra, :booking_desc]
|
|
30
|
-
ALL_FIELDS = LOCALIZED_FIELDS + [:theme_desc, :private_desc, :capacity, :telephone, :email, :website,
|
|
31
|
-
:
|
|
30
|
+
ALL_FIELDS = LOCALIZED_FIELDS + [:theme_desc, :private_desc, :capacity, :telephone, :email, :website,
|
|
31
|
+
:google, :facebook, :twitter, :yelp, :trip_advisor, :fax, :mobile_website, :shorty_url,
|
|
32
|
+
:openings, :openings_extra, :rates, :services, :payment_methods, :categories, :themes,
|
|
33
|
+
:labels, :chains, :classification, :challenged, :environments, :languages, :products,
|
|
34
|
+
:animals, :equipments, :comfort, :activities, :promo, :internal, :linked]
|
|
32
35
|
end
|
data/lib/apidae/version.rb
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//= link_tree ../images
|
data/test/dummy/db/schema.rb
CHANGED
|
@@ -2,15 +2,15 @@
|
|
|
2
2
|
# of editing this file, please use the migrations feature of Active Record to
|
|
3
3
|
# incrementally modify your database, and then regenerate this schema definition.
|
|
4
4
|
#
|
|
5
|
-
#
|
|
6
|
-
#
|
|
7
|
-
#
|
|
8
|
-
# from scratch.
|
|
9
|
-
#
|
|
5
|
+
# This file is the source Rails uses to define your schema when running `bin/rails
|
|
6
|
+
# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to
|
|
7
|
+
# be faster and is potentially less error prone than running all of your
|
|
8
|
+
# migrations from scratch. Old migrations may fail to apply correctly if those
|
|
9
|
+
# migrations use external dependencies or application code.
|
|
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: 2021_06_07_214647) do
|
|
14
14
|
|
|
15
15
|
# These are extensions that must be enabled in order to support this database
|
|
16
16
|
enable_extension "plpgsql"
|
|
@@ -92,8 +92,10 @@ ActiveRecord::Schema.define(version: 2020_05_22_124205) do
|
|
|
92
92
|
t.datetime "created_at", null: false
|
|
93
93
|
t.datetime "updated_at", null: false
|
|
94
94
|
t.jsonb "meta_data"
|
|
95
|
+
t.boolean "is_active"
|
|
95
96
|
t.index ["apidae_id"], name: "index_apidae_references_on_apidae_id"
|
|
96
97
|
t.index ["apidae_type"], name: "index_apidae_references_on_apidae_type"
|
|
98
|
+
t.index ["is_active"], name: "index_apidae_references_on_is_active"
|
|
97
99
|
end
|
|
98
100
|
|
|
99
101
|
create_table "apidae_selection_objects", force: :cascade do |t|
|
|
@@ -112,6 +114,13 @@ ActiveRecord::Schema.define(version: 2020_05_22_124205) do
|
|
|
112
114
|
t.integer "apidae_project_id"
|
|
113
115
|
end
|
|
114
116
|
|
|
117
|
+
create_table "apidae_territories", force: :cascade do |t|
|
|
118
|
+
t.integer "apidae_id"
|
|
119
|
+
t.string "name"
|
|
120
|
+
t.integer "apidae_type"
|
|
121
|
+
t.index ["apidae_id"], name: "index_apidae_territories_on_apidae_id"
|
|
122
|
+
end
|
|
123
|
+
|
|
115
124
|
create_table "apidae_towns", id: :serial, force: :cascade do |t|
|
|
116
125
|
t.string "country"
|
|
117
126
|
t.integer "apidae_id"
|
|
@@ -1,69 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
[1m[35m (0.4ms)[0m [1m[35mCOMMIT[0m
|
|
26
|
-
[1m[36mActiveRecord::InternalMetadata Load (1.9ms)[0m [1m[34mSELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2[0m [["key", "environment"], ["LIMIT", 1]]
|
|
27
|
-
[1m[35m (0.2ms)[0m [1m[35mBEGIN[0m
|
|
28
|
-
[1m[35m (0.1ms)[0m [1m[35mCOMMIT[0m
|
|
29
|
-
[1m[35m (0.2ms)[0m [1m[34mSELECT pg_advisory_unlock(6140174353533887940)[0m
|
|
30
|
-
[1m[35m (0.2ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
|
31
|
-
[1m[35m (0.3ms)[0m [1m[34mSELECT pg_try_advisory_lock(6140174353533887940)[0m
|
|
32
|
-
[1m[35m (3.6ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
|
33
|
-
Migrating to AddBookingDataToApidaeObjs (20190123160046)
|
|
34
|
-
[1m[35m (0.2ms)[0m [1m[35mBEGIN[0m
|
|
35
|
-
[1m[35m (0.7ms)[0m [1m[35mALTER TABLE "apidae_objs" ADD "booking_data" jsonb[0m
|
|
36
|
-
[1m[36mApidae::Obj Load (1.0ms)[0m [1m[34mSELECT "apidae_objs".* FROM "apidae_objs"[0m
|
|
37
|
-
[1m[35m (0.5ms)[0m [1m[35mALTER TABLE "apidae_objs" DROP COLUMN "reservation"[0m
|
|
38
|
-
[1m[36mActiveRecord::SchemaMigration Create (0.3ms)[0m [1m[32mINSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version"[0m [["version", "20190123160046"]]
|
|
39
|
-
[1m[35m (0.6ms)[0m [1m[35mCOMMIT[0m
|
|
40
|
-
[1m[36mActiveRecord::InternalMetadata Load (0.7ms)[0m [1m[34mSELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2[0m [["key", "environment"], ["LIMIT", 1]]
|
|
41
|
-
[1m[35m (0.2ms)[0m [1m[35mBEGIN[0m
|
|
42
|
-
[1m[35m (0.1ms)[0m [1m[35mCOMMIT[0m
|
|
43
|
-
[1m[35m (0.2ms)[0m [1m[34mSELECT pg_advisory_unlock(6140174353533887940)[0m
|
|
44
|
-
[1m[35m (0.2ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
|
45
|
-
[1m[35m (4.5ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
|
46
|
-
[1m[35m (0.2ms)[0m [1m[34mSELECT pg_try_advisory_lock(6140174353533887940)[0m
|
|
47
|
-
[1m[35m (0.6ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
|
48
|
-
Migrating to AddLocalesDataToApidaeProjects (20190123214635)
|
|
49
|
-
[1m[35m (0.2ms)[0m [1m[35mBEGIN[0m
|
|
50
|
-
[1m[35m (3.2ms)[0m [1m[35mALTER TABLE "apidae_projects" ADD "locales_data" character varying[0m
|
|
51
|
-
[1m[36mActiveRecord::SchemaMigration Create (0.3ms)[0m [1m[32mINSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version"[0m [["version", "20190123214635"]]
|
|
52
|
-
[1m[35m (0.5ms)[0m [1m[35mCOMMIT[0m
|
|
53
|
-
[1m[36mActiveRecord::InternalMetadata Load (42.2ms)[0m [1m[34mSELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2[0m [["key", "environment"], ["LIMIT", 1]]
|
|
54
|
-
[1m[35m (0.2ms)[0m [1m[35mBEGIN[0m
|
|
55
|
-
[1m[35m (0.1ms)[0m [1m[35mCOMMIT[0m
|
|
56
|
-
[1m[35m (0.2ms)[0m [1m[34mSELECT pg_advisory_unlock(6140174353533887940)[0m
|
|
57
|
-
[1m[35m (0.2ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
|
58
|
-
[1m[35m (0.5ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
|
59
|
-
[1m[35m (0.2ms)[0m [1m[34mSELECT pg_try_advisory_lock(6140174353533887940)[0m
|
|
60
|
-
[1m[35m (0.5ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
|
61
|
-
[1m[36mActiveRecord::InternalMetadata Load (0.4ms)[0m [1m[34mSELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2[0m [["key", "environment"], ["LIMIT", 1]]
|
|
62
|
-
[1m[35m (0.2ms)[0m [1m[35mBEGIN[0m
|
|
63
|
-
[1m[35m (0.2ms)[0m [1m[35mCOMMIT[0m
|
|
64
|
-
[1m[35m (0.2ms)[0m [1m[34mSELECT pg_advisory_unlock(6140174353533887940)[0m
|
|
65
|
-
[1m[35m (0.2ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
|
66
|
-
[1m[36mApidae::Obj Load (26.8ms)[0m [1m[34mSELECT apidae_id, COUNT(id) FROM "apidae_objs" WHERE "apidae_objs"."root_obj_id" IS NULL GROUP BY "apidae_objs"."apidae_id" HAVING (COUNT(id) > 1)[0m
|
|
67
|
-
[1m[36mApidae::Obj Load (2.4ms)[0m [1m[34mSELECT apidae_id, COUNT(id) FROM "apidae_objs" WHERE "apidae_objs"."root_obj_id" IS NULL GROUP BY "apidae_objs"."apidae_id" HAVING (COUNT(id) > 1)[0m
|
|
68
|
-
[1m[36mApidae::Obj Load (0.8ms)[0m [1m[34mSELECT "apidae_objs".* FROM "apidae_objs" ORDER BY "apidae_objs"."id" ASC LIMIT $1[0m [["LIMIT", 1]]
|
|
69
|
-
[1m[35m (3.4ms)[0m [1m[34mSELECT COUNT(*) FROM "apidae_objs"[0m
|
|
1
|
+
DEPRECATION WARNING: Initialization autoloaded the constants Apidae::ApidaeHelper, Apidae::ApplicationHelper, Apidae::ApiHelper, Apidae::DashboardHelper, Apidae::ExtendableHelper, Apidae::ImportHelper, Apidae::ObjectsHelper, Apidae::ReferencesHelper, Apidae::SelectionsHelper, and Apidae::ApplicationController.
|
|
2
|
+
|
|
3
|
+
Being able to do this is deprecated. Autoloading during initialization is going
|
|
4
|
+
to be an error condition in future versions of Rails.
|
|
5
|
+
|
|
6
|
+
Reloading does not reboot the application, and therefore code executed during
|
|
7
|
+
initialization does not run again. So, if you reload Apidae::ApidaeHelper, for example,
|
|
8
|
+
the expected changes won't be reflected in that stale Module object.
|
|
9
|
+
|
|
10
|
+
`config.autoloader` is set to `classic`. These autoloaded constants would have been unloaded if `config.autoloader` had been set to `:zeitwerk`.
|
|
11
|
+
|
|
12
|
+
In order to autoload safely at boot time, please wrap your code in a reloader
|
|
13
|
+
callback this way:
|
|
14
|
+
|
|
15
|
+
Rails.application.reloader.to_prepare do
|
|
16
|
+
# Autoload classes and modules needed at boot time here.
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
That block runs when the application boots, and every time there is a reload.
|
|
20
|
+
For historical reasons, it may run twice, so it has to be idempotent.
|
|
21
|
+
|
|
22
|
+
Check the "Autoloading and Reloading Constants" guide to learn more about how
|
|
23
|
+
Rails autoloads and reloads.
|
|
24
|
+
(called from <top (required)> at /Users/jbvilain/workspace/apidae-engine-rails/test/dummy/config/environment.rb:5)
|
|
@@ -166,6 +166,29 @@ module Apidae
|
|
|
166
166
|
assert_equal 0, Selection.count
|
|
167
167
|
end
|
|
168
168
|
|
|
169
|
+
test "object deletion cancelled if used by another project" do
|
|
170
|
+
proj = Project.create(apidae_id: 123)
|
|
171
|
+
other_proj = Project.create(apidae_id: 456)
|
|
172
|
+
sel = Selection.create(apidae_id: 49063, apidae_project_id: proj.id, label: 'Sélection 2', reference: 'selection-2')
|
|
173
|
+
other_sel = Selection.create(apidae_id: 49999, apidae_project_id: other_proj.id, label: 'Sélection 99', reference: 'selection-99')
|
|
174
|
+
sel.objects << Obj.create(apidae_id: 503, title: 'Société des violoncellistes aixois')
|
|
175
|
+
sel.objects << Obj.create(apidae_id: 504, title: 'Société des contrebassistes aixois')
|
|
176
|
+
other_sel.objects << Obj.find_by_apidae_id(504)
|
|
177
|
+
|
|
178
|
+
assert_equal 2, sel.objects.count
|
|
179
|
+
assert_equal 1, other_sel.objects.count
|
|
180
|
+
|
|
181
|
+
selections_json = File.read('test/data/shared_selections.json')
|
|
182
|
+
FileImport.add_or_update_selections(proj, selections_json, @result)
|
|
183
|
+
deletion_json = File.read('test/data/deletion.json')
|
|
184
|
+
FileImport.delete_objects(deletion_json, @result)
|
|
185
|
+
|
|
186
|
+
assert_equal 2, Obj.count
|
|
187
|
+
assert_equal({created: 0, updated: 0, deleted: 1, selections:
|
|
188
|
+
[{:apidae_id=>49063, :reference=>"selection-2", :objects=>1}]}, @result)
|
|
189
|
+
assert_equal 1, other_sel.objects.count
|
|
190
|
+
end
|
|
191
|
+
|
|
169
192
|
test "full import process" do
|
|
170
193
|
Obj.create(apidae_id: 123, title: 'Objet à supprimer')
|
|
171
194
|
Obj.create(apidae_id: 4826186, title: 'Objet à mettre à jour')
|
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: 1.3.
|
|
4
|
+
version: 1.3.7
|
|
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:
|
|
11
|
+
date: 2022-01-23 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rails
|
|
@@ -209,10 +209,12 @@ files:
|
|
|
209
209
|
- test/data/hot_fr_en.json
|
|
210
210
|
- test/data/json_export.zip
|
|
211
211
|
- test/data/selections.json
|
|
212
|
+
- test/data/shared_selections.json
|
|
212
213
|
- test/data/structure.json
|
|
213
214
|
- test/data/update_selections.json
|
|
214
215
|
- test/dummy/README.rdoc
|
|
215
216
|
- test/dummy/Rakefile
|
|
217
|
+
- test/dummy/app/assets/config/manifest.js
|
|
216
218
|
- test/dummy/app/assets/javascripts/application.js
|
|
217
219
|
- test/dummy/app/assets/stylesheets/application.css
|
|
218
220
|
- test/dummy/app/controllers/application_controller.rb
|
|
@@ -245,7 +247,6 @@ files:
|
|
|
245
247
|
- test/dummy/config/secrets.yml
|
|
246
248
|
- test/dummy/db/schema.rb
|
|
247
249
|
- test/dummy/log/development.log
|
|
248
|
-
- test/dummy/log/test.log
|
|
249
250
|
- test/dummy/public/404.html
|
|
250
251
|
- test/dummy/public/422.html
|
|
251
252
|
- test/dummy/public/500.html
|
|
@@ -284,14 +285,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
284
285
|
- !ruby/object:Gem::Version
|
|
285
286
|
version: '0'
|
|
286
287
|
requirements: []
|
|
287
|
-
|
|
288
|
-
rubygems_version: 2.6.13
|
|
288
|
+
rubygems_version: 3.1.6
|
|
289
289
|
signing_key:
|
|
290
290
|
specification_version: 4
|
|
291
291
|
summary: A Ruby on Rails engine for projects that involve Apidae data
|
|
292
292
|
test_files:
|
|
293
293
|
- test/dummy/app/controllers/application_controller.rb
|
|
294
294
|
- test/dummy/app/views/layouts/application.html.erb
|
|
295
|
+
- test/dummy/app/assets/config/manifest.js
|
|
295
296
|
- test/dummy/app/assets/javascripts/application.js
|
|
296
297
|
- test/dummy/app/assets/stylesheets/application.css
|
|
297
298
|
- test/dummy/app/helpers/application_helper.rb
|
|
@@ -326,7 +327,6 @@ test_files:
|
|
|
326
327
|
- test/dummy/public/500.html
|
|
327
328
|
- test/dummy/public/404.html
|
|
328
329
|
- test/dummy/db/schema.rb
|
|
329
|
-
- test/dummy/log/test.log
|
|
330
330
|
- test/dummy/log/development.log
|
|
331
331
|
- test/dummy/README.rdoc
|
|
332
332
|
- test/integration/navigation_test.rb
|
|
@@ -351,6 +351,7 @@ test_files:
|
|
|
351
351
|
- test/controllers/apidae/dashboard_controller_test.rb
|
|
352
352
|
- test/controllers/apidae/references_controller_test.rb
|
|
353
353
|
- test/controllers/apidae/import_controller_test.rb
|
|
354
|
+
- test/data/shared_selections.json
|
|
354
355
|
- test/data/equ_groups.json
|
|
355
356
|
- test/data/update_selections.json
|
|
356
357
|
- test/data/json_export.zip
|