apidae 0.9.31 → 0.9.34
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/app/models/apidae/file_import.rb +4 -1
- data/app/models/apidae/obj.rb +13 -5
- data/app/models/apidae/project.rb +6 -0
- data/app/models/apidae/selection.rb +14 -0
- data/lib/apidae/version.rb +1 -1
- data/test/dummy/log/development.log +216 -350
- data/test/dummy/log/test.log +690 -7109
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 19f4dc1ae011dc6f13e271bbbbff28eb59710068d444c21c8ac6bf4952f423b9
|
4
|
+
data.tar.gz: 03d28c16f13a83a89918c5b8a790b9651975f68cb681c356c0e065a553b6eaed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 18eaa64392193791632314d650ace16fc3cb8f795b3c50b222ecdb76b50ce9501fd8cc2bca664cbbf6941359f0a2d9ac0a23c637d0cec20cab32ccc971bfca69
|
7
|
+
data.tar.gz: 35ebab3b19a709f29e3d75e1abe93563395fa2fa3b50d8c8c93734290973b9ba3e8438f3977c4433d6a820ee6d0f87ef1c0fd7551a2d343b42dd71031d2d71b1
|
@@ -45,6 +45,7 @@ module Apidae
|
|
45
45
|
end
|
46
46
|
end
|
47
47
|
end
|
48
|
+
project.cleanup_selections
|
48
49
|
create(result.except(:selections)
|
49
50
|
.merge({remote_file: (zip_file.is_a?(File) ? zip_file.path : zip_file), status: STATUS_COMPLETE, apidae_id: project_id}))
|
50
51
|
logger.info "Import results : #{result}"
|
@@ -170,7 +171,9 @@ module Apidae
|
|
170
171
|
def self.add_or_update_selections(project, selections_json, result)
|
171
172
|
selections_hashes = JSON.parse(selections_json, symbolize_names: true)
|
172
173
|
deleted_ids = Selection.where(apidae_project_id: project.id).collect {|sel| sel.apidae_id}.uniq - selections_hashes.collect {|sel| sel[:id]}
|
173
|
-
Selection.where(apidae_id: deleted_ids).
|
174
|
+
apidae_selection_ids = Selection.where(apidae_id: deleted_ids).map {|s| s.id}
|
175
|
+
SelectionObject.where(apidae_selection_id: apidae_selection_ids).delete_all
|
176
|
+
Selection.where(id: apidae_selection_ids).delete_all
|
174
177
|
selections_hashes.each do |selection_data|
|
175
178
|
logger.info "Updating selection #{selection_data[:id]}"
|
176
179
|
Selection.add_or_update(selection_data, project.id)
|
data/app/models/apidae/obj.rb
CHANGED
@@ -14,12 +14,12 @@ module Apidae
|
|
14
14
|
store_accessor :pictures_data, :pictures
|
15
15
|
store_accessor :attachments_data, :attachments
|
16
16
|
store_accessor :type_data, :categories, :themes, :capacity, :classification, :labels, :chains, :area, :track,
|
17
|
-
:products, :audience, :animals, :extra, :duration, :certifications, :business
|
17
|
+
:products, :audience, :animals, :extra, :duration, :certifications, :business, :complement
|
18
18
|
store_accessor :entity_data, :entity_id, :entity_name, :service_provider_id
|
19
19
|
store_accessor :contact, :telephone, :email, :website
|
20
20
|
store_accessor :location_data, :address, :place, :latitude, :longitude, :access, :territories, :environments
|
21
21
|
store_accessor :openings_data, :openings_desc, :openings_desc_mode, :openings, :time_periods, :openings_extra
|
22
|
-
store_accessor :rates_data, :rates_desc, :rates_desc_mode, :rates, :payment_methods, :includes, :excludes
|
22
|
+
store_accessor :rates_data, :rates_desc, :rates_desc_mode, :rates, :payment_methods, :includes, :excludes, :rates_complement
|
23
23
|
store_accessor :service_data, :services, :equipments, :comfort, :activities, :challenged, :languages
|
24
24
|
store_accessor :booking_data, :booking_desc, :booking_entities
|
25
25
|
store_accessor :tags_data, :promo, :internal, :linked
|
@@ -293,12 +293,18 @@ module Apidae
|
|
293
293
|
when PHONE
|
294
294
|
contact_details[:telephone] ||= []
|
295
295
|
contact_details[:telephone] << c[:coordonnees][:fr]
|
296
|
+
contact_details[:telephone_details] ||= []
|
297
|
+
contact_details[:telephone_details] << {value: c[:coordonnees][:fr], description: c.dig(:observation, :libelleFr)}
|
296
298
|
when EMAIL
|
297
299
|
contact_details[:email] ||= []
|
298
300
|
contact_details[:email] << c[:coordonnees][:fr]
|
301
|
+
contact_details[:email_details] ||= []
|
302
|
+
contact_details[:email_details] << {value: c[:coordonnees][:fr], description: c.dig(:observation, :libelleFr)}
|
299
303
|
when WEBSITE
|
300
304
|
contact_details[:website] ||= []
|
301
305
|
contact_details[:website] << c[:coordonnees][:fr]
|
306
|
+
contact_details[:website_details] ||= []
|
307
|
+
contact_details[:website_details] << {value: c[:coordonnees][:fr], description: c.dig(:observation, :libelleFr)}
|
302
308
|
else
|
303
309
|
end
|
304
310
|
end
|
@@ -360,7 +366,8 @@ module Apidae
|
|
360
366
|
rates_desc: desc, rates: values, payment_methods: methods,
|
361
367
|
rates_desc_mode: rates_hash[:tarifsEnClairGenerationMode] == 'AUTOMATIQUE' ? MODE_AUTO : MODE_MANUAL,
|
362
368
|
includes: node_value(rates_hash, :leTarifComprend, *locales),
|
363
|
-
excludes: node_value(rates_hash, :leTarifNeComprendPas, *locales)
|
369
|
+
excludes: node_value(rates_hash, :leTarifNeComprendPas, *locales),
|
370
|
+
rates_complement: node_value(rates_hash, :complement, *locales)
|
364
371
|
}
|
365
372
|
end
|
366
373
|
end
|
@@ -390,7 +397,8 @@ module Apidae
|
|
390
397
|
extra: apidae_obj.apidae_type == SPA ? node_value(data_hash, :formuleHebergement, *locales) : node_value(prestations_hash, :complementAccueil, *locales),
|
391
398
|
duration: apidae_obj.apidae_type == SPA ? {days: data_hash[:nombreJours], nights: data_hash[:nombreNuits]} : data_hash[:dureeSeance],
|
392
399
|
certifications: data_hash[:agrements].blank? ? [] : data_hash[:agrements].map {|a| {id: a[:type][:id], identifier: a[:numero]}},
|
393
|
-
business: business_hash
|
400
|
+
business: business_hash,
|
401
|
+
complement: apidae_obj.apidae_type == SPA ? node_value(prestations_hash, :complementAccueil, *locales) : {},
|
394
402
|
}
|
395
403
|
end
|
396
404
|
|
@@ -419,7 +427,7 @@ module Apidae
|
|
419
427
|
end
|
420
428
|
unless linked_data_hash.blank? || linked_data_hash[:liensObjetsTouristiquesTypes].blank?
|
421
429
|
tags[:linked] = linked_data_hash[:liensObjetsTouristiquesTypes]
|
422
|
-
.map {|l| {apidae_id: l[:objetTouristique][:id], apidae_type: l[:objetTouristique][:type], category: l[:type]}}
|
430
|
+
.map {|l| {apidae_id: l[:objetTouristique][:id], apidae_type: l[:objetTouristique][:type], category: l[:type], name: l[:objetTouristique][:nom]}}
|
423
431
|
end
|
424
432
|
tags
|
425
433
|
end
|
@@ -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
|
data/lib/apidae/version.rb
CHANGED