apidae 1.3.5 → 1.3.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/apidae/apidae_data_parser.rb +19 -5
- data/app/models/apidae/file_import.rb +4 -2
- data/app/models/apidae/obj.rb +6 -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/{app → test/dummy/app}/assets/config/manifest.js +0 -0
- data/test/dummy/db/schema.rb +15 -6
- data/test/dummy/log/development.log +48 -350
- data/test/dummy/log/test.log +657 -8486
- data/test/models/apidae/obj_test.rb +10 -3
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fcb280b4660f8ea2bbcf7ee76a7b618c00bcf9e363423fae013ce626681b2108
|
4
|
+
data.tar.gz: 073b41e45931ee6690e4edc8e8c07b3f0ca2ec6479471a2726a6e43033a9e6e2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a82f16675847e98e2115f06b4185648625eeb2c3d7ebda7967e32cad3e816073a3bccc0549dc6ae4f7eb59465f559459ce32e7d79453b9878ba60527dc54d84e
|
7
|
+
data.tar.gz: c80d4e36df23e913c9a52062eb657a86582be9c9911c7c53289ec638ea0cd41d4d1506e189fad859e70475f099fb6c373d3b141ec87322a5d8a93f596ca1f86e
|
@@ -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
|
@@ -253,6 +253,7 @@ module Apidae
|
|
253
253
|
methods = rates_hash[:modesPaiement].blank? ? [] : rates_hash[:modesPaiement].map {|p| p[:id]}
|
254
254
|
{
|
255
255
|
rates_desc: desc, rates: values, payment_methods: methods,
|
256
|
+
tax_included: rates_hash[:taxeDeSejourIncluse].blank? ? nil : (rates_hash[:taxeDeSejourIncluse] == 'OUI'),
|
256
257
|
rates_desc_mode: rates_hash[:tarifsEnClairGenerationMode] == 'AUTOMATIQUE' ? MODE_AUTO : MODE_MANUAL,
|
257
258
|
includes: node_value(rates_hash, :leTarifComprend, *locales),
|
258
259
|
excludes: node_value(rates_hash, :leTarifNeComprendPas, *locales),
|
@@ -275,6 +276,8 @@ module Apidae
|
|
275
276
|
age_min: presta_hash[:ageMin], age_max: presta_hash[:ageMax]} : {}),
|
276
277
|
classification: nodes_ids(data_hash[:classement], data_hash[:classementPrefectoral], data_hash[:classification]) +
|
277
278
|
lists_ids(data_hash[:classementsGuides]) + lists_ids(data_hash[:classements]),
|
279
|
+
classification_date: data_hash[:dateClassement],
|
280
|
+
classification_ref: data_hash[:numeroClassement],
|
278
281
|
labels: lists_ids(data_hash[:labels], data_hash[:labelsChartesQualite], prestations_hash[:labelsTourismeHandicap]) +
|
279
282
|
(node_id(data_hash, :typeLabel) ? [node_id(data_hash, :typeLabel)] : []),
|
280
283
|
chains: lists_ids(data_hash[:chaines]) + nodes_ids(data_hash[:chaineEtLabel]),
|
@@ -288,7 +291,10 @@ module Apidae
|
|
288
291
|
extra: apidae_obj.apidae_type == Obj::SPA ? node_value(data_hash, :formuleHebergement, *locales) : node_value(prestations_hash, :complementAccueil, *locales),
|
289
292
|
duration: apidae_obj.apidae_type == Obj::SPA ? {days: data_hash[:nombreJours], nights: data_hash[:nombreNuits]} : data_hash[:dureeSeance],
|
290
293
|
certifications: data_hash[:agrements].blank? ? [] : data_hash[:agrements].map {|a| {id: a[:type][:id], identifier: a[:numero]}},
|
291
|
-
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]
|
292
298
|
}
|
293
299
|
end
|
294
300
|
|
@@ -325,12 +331,14 @@ module Apidae
|
|
325
331
|
def self.parse_booking(reservation_hash, visits_hash, *locales)
|
326
332
|
booking_hash = {}
|
327
333
|
if reservation_hash
|
328
|
-
booking_hash[:booking_desc] = node_value(reservation_hash, :complement, *locales)
|
334
|
+
booking_hash[:booking_desc] = node_value(reservation_hash, :complement, *locales)
|
329
335
|
booking_hash[:booking_entities] = reservation_hash[:organismes]
|
330
336
|
end
|
331
337
|
if visits_hash
|
332
338
|
booking_hash[:visits_allowed] = visits_hash[:visitable] == true
|
333
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])
|
334
342
|
end
|
335
343
|
booking_hash
|
336
344
|
end
|
@@ -346,8 +354,14 @@ module Apidae
|
|
346
354
|
|
347
355
|
def self.parse_entity_fields(information_hash, type_data_hash, sp_hash)
|
348
356
|
entity_hash = {}
|
349
|
-
if information_hash
|
350
|
-
|
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
|
351
365
|
end
|
352
366
|
if sp_hash && sp_hash[:prestataireActivites]
|
353
367
|
entity_hash[:is_service_provider] = true
|
@@ -31,7 +31,6 @@ module Apidae
|
|
31
31
|
logger.info "Completed #{Town.count} towns update"
|
32
32
|
end
|
33
33
|
ordered_files(zfile).each do |file|
|
34
|
-
puts "processing #{file.name}"
|
35
34
|
if file.file? && file.name.end_with?('.json')
|
36
35
|
logger.info "Processing file : #{file.name}"
|
37
36
|
if file.name.include?(MODIFIED_DIR)
|
@@ -45,6 +44,7 @@ module Apidae
|
|
45
44
|
end
|
46
45
|
end
|
47
46
|
end
|
47
|
+
project.cleanup_selections
|
48
48
|
create(result.except(:selections)
|
49
49
|
.merge({remote_file: (zip_file.is_a?(File) ? zip_file.path : zip_file), status: STATUS_COMPLETE, apidae_id: project_id}))
|
50
50
|
logger.info "Import results : #{result}"
|
@@ -170,7 +170,9 @@ module Apidae
|
|
170
170
|
def self.add_or_update_selections(project, selections_json, result)
|
171
171
|
selections_hashes = JSON.parse(selections_json, symbolize_names: true)
|
172
172
|
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).
|
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
|
174
176
|
selections_hashes.each do |selection_data|
|
175
177
|
logger.info "Updating selection #{selection_data[:id]}"
|
176
178
|
Selection.add_or_update(selection_data, project.id)
|
data/app/models/apidae/obj.rb
CHANGED
@@ -14,16 +14,17 @@ module Apidae
|
|
14
14
|
store_accessor :description_data, :short_desc, :long_desc, :theme_desc, :private_desc
|
15
15
|
store_accessor :pictures_data, :pictures
|
16
16
|
store_accessor :attachments_data, :attachments
|
17
|
-
store_accessor :type_data, :categories, :themes, :capacity, :classification, :
|
18
|
-
:
|
19
|
-
|
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
|
20
21
|
store_accessor :contact_data, :telephone, :email, :website, :google, :facebook, :twitter, :yelp, :trip_advisor, :fax,
|
21
22
|
:mobile_website, :shorty_url, :contacts
|
22
23
|
store_accessor :location_data, :address, :place, :latitude, :longitude, :access, :territories, :environments, :altitude, :map_reference
|
23
24
|
store_accessor :openings_data, :openings_desc, :openings_desc_mode, :openings, :time_periods, :openings_extra
|
24
|
-
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
|
25
26
|
store_accessor :service_data, :services, :equipments, :comfort, :activities, :challenged, :languages
|
26
|
-
store_accessor :booking_data, :booking_desc, :booking_entities, :visits_allowed, :visits_desc
|
27
|
+
store_accessor :booking_data, :booking_desc, :booking_entities, :visits_allowed, :visits_desc, :visits_duration, :visits_services
|
27
28
|
store_accessor :tags_data, :promo, :internal, :linked
|
28
29
|
store_accessor :version_data, :versioned_fields
|
29
30
|
|
@@ -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
File without changes
|
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"
|