apidae 1.2.27 → 1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA256:
3
- metadata.gz: 1a6d99e78f384b6bf1807fc9a6ba07cda1f9bff30ed932c2ae6ebccb229f354a
4
- data.tar.gz: c52c6b9221392e353b863ef489d6fd1f739036b137a1d627e8b525c9e81f6cd4
2
+ SHA1:
3
+ metadata.gz: 11f5031e46f8bfa23ce228c242e023c4ebe10e0e
4
+ data.tar.gz: '0083f65ff4cfbd3f53c5a13126ca940c4be696ae'
5
5
  SHA512:
6
- metadata.gz: c407158dba1f94aff7b68a11782717deb4b7d81f55ca3f9defa74752de7bd78a1cdece35ae203c9e8db032c23e6c35c25164c1d1e0b00b1714b64a7506e33d22
7
- data.tar.gz: 7110133dca759d1df90aec75b1f83fae826aae1a2ba3282eca456ca7ba6a4274c25aaad3b46a4dea3cf337299e78d6a65e40de55d4297fbca69b92bee2bace8f
6
+ metadata.gz: 0a6544dae89ca3cee7525b37433fc6941b5ae76d720f2adce045d3357fd65efca3150885b0cb9da8234a5324218448e57545897865a77896e1bdfe7a462ab31b
7
+ data.tar.gz: 9c51ebdb6c1d9d671499fd60f086a8c43feb94a9c77d06108aa030b73d5bce00ad4fd5b58e0f5467d21a509bcc1594c2c59f6d19e4be2f61a78d76fc04037b3b
@@ -37,7 +37,7 @@ module Apidae
37
37
  def run
38
38
  success = true
39
39
  Export.pending.each do |e|
40
- success &&= import_data(e)
40
+ success &&= e.import_data
41
41
  end
42
42
  success ? head(:ok) : head(:internal_server_error)
43
43
  end
@@ -48,7 +48,7 @@ module Apidae
48
48
 
49
49
  def create
50
50
  @export = Export.new(export_params)
51
- if @export.save && import_data(@export)
51
+ if @export.save && @export.import_data
52
52
  redirect_to apidae.root_url, notice: 'Le fichier a bien été importé.'
53
53
  else
54
54
  flash.now[:alert] = "Une erreur s'est produite lors de l'import du fichier."
@@ -61,43 +61,5 @@ module Apidae
61
61
  def export_params
62
62
  params.require(:export).permit(:project_id, :file_url, :status)
63
63
  end
64
-
65
- def import_data(e)
66
- success = true
67
- begin
68
- open(e.file_url) do |f|
69
- begin
70
- FileImport.import(f, e.project_id)
71
- unless e.confirm_url.blank?
72
- uri = URI(e.confirm_url)
73
- req = Net::HTTP::Post.new(uri)
74
- Net::HTTP.start(uri.hostname, uri.port) do |http|
75
- http.request(req)
76
- end
77
- end
78
- e.update(status: Export::COMPLETE)
79
- if Rails.application.config.respond_to?(:apidae_import_callback)
80
- Rails.application.config.apidae_import_callback.call(e)
81
- end
82
- rescue Exception => ex
83
- logger.error("Failed to import export file : #{e.file_url}")
84
- logger.error("Error is : #{ex} \n#{ex.backtrace.join("\n") unless ex.backtrace.blank?}")
85
- success = false
86
- e.update(status: Export::CANCELLED)
87
- end
88
- end
89
- rescue OpenURI::HTTPError => err
90
- logger.error("Failed to download export file : #{e.file_url}")
91
- logger.error("Error is : #{err}")
92
- success = false
93
- e.update(status: Export::CANCELLED)
94
- rescue Exception => e
95
- logger.error "Failed to import file : #{e.file_url}"
96
- logger.error("Error is : #{err}")
97
- success = false
98
- e.update(status: Export::CANCELLED)
99
- end
100
- success
101
- end
102
64
  end
103
65
  end
@@ -1,6 +1,6 @@
1
1
  module Apidae
2
2
  module ApplicationHelper
3
- include Apidae::ApidaeHelper
3
+ include ApidaeHelper
4
4
 
5
5
  def apidae_user
6
6
  send(Rails.application.config.apidae_user) if Rails.application.config.respond_to?(:apidae_user)
@@ -44,7 +44,7 @@ module Apidae
44
44
  'LUNDI' => MONDAY,
45
45
  'MARDI' => TUESDAY,
46
46
  'MERCREDI' => WEDNESDAY,
47
- 'JEUDI' => THURSDAY,
47
+ 'JEUD' => THURSDAY,
48
48
  'VENDREDI' => FRIDAY,
49
49
  'SAMEDI' => SATURDAY,
50
50
  'DIMANCHE' => SUNDAY
@@ -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).blank? ? {LOCALE_FR => d[:libelleFr]} : node_value(d, :descriptif, *locales))]}]
116
+ private_desc: private_data.blank? ? {} : Hash[private_data.map {|d| [d[:nomTechnique], node_value(d, :descriptif, *locales)]}]
117
117
  }
118
118
  end
119
119
  end
@@ -151,7 +151,6 @@ 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],
155
154
  description: localized_value(att, :legende, locale)
156
155
  }
157
156
  end
@@ -223,8 +222,6 @@ module Apidae
223
222
  loc_data[:latitude] = geoloc_details[:geoJson][:coordinates][1]
224
223
  loc_data[:longitude] = geoloc_details[:geoJson][:coordinates][0]
225
224
  end
226
- loc_data[:map_reference] = geoloc_details[:reperePlan]
227
- loc_data[:altitude] = geoloc_details[:altitude] if geoloc_details
228
225
  loc_data[:access] = node_value(geoloc_details, :complement) if geoloc_details
229
226
  loc_data[:environments] = location_hash[:environnements].map {|e| e[:id]} if location_hash[:environnements]
230
227
  end
@@ -239,7 +236,6 @@ module Apidae
239
236
  openings_desc: node_value(openings_hash, :periodeEnClair, *locales),
240
237
  openings_desc_mode: openings_hash[:periodeEnClairGenerationMode] == 'AUTOMATIQUE' ? MODE_AUTO : MODE_MANUAL,
241
238
  openings: build_openings(openings_hash, *locales),
242
- all_year_long: openings_hash[:ouvertTouteLAnnee] == 'OUVERT_TOUTE_L_ANNEE' ? 'true' : 'false',
243
239
  time_periods: lists_ids(openings_hash[:indicationsPeriode]),
244
240
  openings_extra: lists_ids(openings_hash[:ouverturesComplementaires])
245
241
  }
@@ -251,10 +247,8 @@ module Apidae
251
247
  desc = rates_hash[:gratuit] ? {DEFAULT_LOCALE => 'gratuit'} : node_value(rates_hash, :tarifsEnClair, *locales)
252
248
  values = rates_hash[:periodes].blank? ? [] : rates_hash[:periodes].map {|p| build_rate(p, *locales)}
253
249
  methods = rates_hash[:modesPaiement].blank? ? [] : rates_hash[:modesPaiement].map {|p| p[:id]}
254
-
255
250
  {
256
251
  rates_desc: desc, rates: values, payment_methods: methods,
257
- tax_included: rates_hash[:taxeDeSejourIncluse].blank? ? nil : (rates_hash[:taxeDeSejourIncluse] == 'OUI'),
258
252
  rates_desc_mode: rates_hash[:tarifsEnClairGenerationMode] == 'AUTOMATIQUE' ? MODE_AUTO : MODE_MANUAL,
259
253
  includes: node_value(rates_hash, :leTarifComprend, *locales),
260
254
  excludes: node_value(rates_hash, :leTarifNeComprendPas, *locales),
@@ -270,21 +264,18 @@ module Apidae
270
264
  apidae_obj.apidae_subtype = node_id(data_hash, :rubrique) if apidae_obj.apidae_type == Obj::EQU
271
265
  apidae_obj.apidae_subtype = lists_ids(data_hash[:typesHebergement]).first if apidae_obj.apidae_type == Obj::SPA
272
266
  {
273
- categories: lists_ids(data_hash[:categories], data_hash[:typesDetailles], data_hash[:activiteCategories], data_hash[:typesHabitation]),
267
+ categories: lists_ids(data_hash[:categories], data_hash[:typesDetailles], data_hash[:activiteCategories]),
274
268
  themes: lists_ids(data_hash[:themes]),
275
269
  capacity: (data_hash[:capacite] || {})
276
270
  .merge(presta_hash ? {group_min: presta_hash[:tailleGroupeMin], group_max: presta_hash[:tailleGroupeMax],
277
271
  age_min: presta_hash[:ageMin], age_max: presta_hash[:ageMax]} : {}),
278
272
  classification: nodes_ids(data_hash[:classement], data_hash[:classementPrefectoral], data_hash[:classification]) +
279
273
  lists_ids(data_hash[:classementsGuides]) + lists_ids(data_hash[:classements]),
280
- classification_date: data_hash[:dateClassement],
281
- classification_ref: data_hash[:numeroClassement],
282
274
  labels: lists_ids(data_hash[:labels], data_hash[:labelsChartesQualite], prestations_hash[:labelsTourismeHandicap]) +
283
275
  (node_id(data_hash, :typeLabel) ? [node_id(data_hash, :typeLabel)] : []),
284
276
  chains: lists_ids(data_hash[:chaines]) + nodes_ids(data_hash[:chaineEtLabel]),
285
277
  area: apidae_obj.apidae_type == Obj::DOS ? data_hash.except(:classification) : node_value(data_hash, :lieuDePratique),
286
- track: apidae_obj.apidae_type == Obj::EQU ? (data_hash[:itineraire] || {}).except(:passagesDelicats) : nil,
287
- tricky_sections: apidae_obj.apidae_type == Obj::EQU ? node_value(data_hash[:itineraire], :passagesDelicats, *locales) : nil,
278
+ track: apidae_obj.apidae_type == Obj::EQU ? data_hash[:itineraire] : nil,
288
279
  products: lists_ids(data_hash[:typesProduit], data_hash[:aopAocIgps], data_hash[:specialites]),
289
280
  audience: lists_ids(prestations_hash[:typesClientele]),
290
281
  animals: {allowed: prestations_hash[:animauxAcceptes] == 'ACCEPTES', desc: node_value(prestations_hash, :descriptifAnimauxAcceptes, *locales),
@@ -292,10 +283,7 @@ module Apidae
292
283
  extra: apidae_obj.apidae_type == Obj::SPA ? node_value(data_hash, :formuleHebergement, *locales) : node_value(prestations_hash, :complementAccueil, *locales),
293
284
  duration: apidae_obj.apidae_type == Obj::SPA ? {days: data_hash[:nombreJours], nights: data_hash[:nombreNuits]} : data_hash[:dureeSeance],
294
285
  certifications: data_hash[:agrements].blank? ? [] : data_hash[:agrements].map {|a| {id: a[:type][:id], identifier: a[:numero]}},
295
- business: (business_hash || {}).except(:sallesEquipeesPour, :sallesEquipement, :sallesRestauration, :sallesReunion, :sallesHebergement),
296
- business_equipments: lists_ids((business_hash || {})[:sallesEquipeesPour], (business_hash || {})[:sallesEquipement],
297
- (business_hash || {})[:sallesRestauration], (business_hash || {})[:sallesHebergement]),
298
- business_rooms: (business_hash || {})[:sallesReunion]
286
+ business: business_hash
299
287
  }
300
288
  end
301
289
 
@@ -329,19 +317,13 @@ module Apidae
329
317
  tags
330
318
  end
331
319
 
332
- def self.parse_booking(reservation_hash, visits_hash, *locales)
333
- booking_hash = {}
320
+ def self.parse_booking(reservation_hash, *locales)
334
321
  if reservation_hash
335
- booking_hash[:booking_desc] = node_value(reservation_hash, :complement, *locales),
336
- booking_hash[:booking_entities] = reservation_hash[:organismes]
337
- end
338
- if visits_hash
339
- booking_hash[:visits_allowed] = visits_hash[:visitable] == true
340
- booking_hash[:visits_desc] = node_value(visits_hash, :complementVisite, *locales)
341
- booking_hash[:visits_duration] = visits_hash[:dureeMoyenneVisiteIndividuelle]
342
- booking_hash[:visits_services] = lists_ids(visits_hash[:prestationsVisitesGroupees]) + lists_ids(visits_hash[:prestationsVisitesIndividuelles])
322
+ {
323
+ booking_desc: node_value(reservation_hash, :complement, *locales),
324
+ booking_entities: reservation_hash[:organismes]
325
+ }
343
326
  end
344
- booking_hash
345
327
  end
346
328
 
347
329
  def self.parse_town(location_hash)
@@ -353,21 +335,10 @@ module Apidae
353
335
  end
354
336
  end
355
337
 
356
- def self.parse_entity_fields(information_hash, type_data_hash, sp_hash)
357
- entity_hash = {}
358
- if information_hash
359
- if information_hash[:structureGestion]
360
- entity_hash.merge!({entity_id: information_hash[:structureGestion][:id], service_provider_id: node_id(type_data_hash, :prestataireActivites)})
361
- end
362
-
363
- if information_hash[:informationsLegales]
364
- entity_hash.merge!({legal: information_hash[:informationsLegales]})
365
- end
366
- end
367
- if sp_hash && sp_hash[:prestataireActivites]
368
- entity_hash[:is_service_provider] = true
338
+ def self.parse_entity_fields(information_hash, type_data_hash)
339
+ if information_hash && information_hash[:structureGestion]
340
+ {entity_id: information_hash[:structureGestion][:id], service_provider_id: node_id(type_data_hash, :prestataireActivites)}
369
341
  end
370
- entity_hash
371
342
  end
372
343
 
373
344
  def self.node_id(node, key)
@@ -1,3 +1,6 @@
1
+ require 'uri'
2
+ require 'net/http'
3
+
1
4
  module Apidae
2
5
  class Export < ActiveRecord::Base
3
6
 
@@ -20,5 +23,43 @@ module Apidae
20
23
  def self.pending
21
24
  where(remote_status: 'SUCCESS', status: PENDING).order(:id)
22
25
  end
26
+
27
+ def import_data
28
+ success = true
29
+ begin
30
+ open(file_url) do |f|
31
+ begin
32
+ FileImport.import(f, project_id)
33
+ unless confirm_url.blank?
34
+ uri = URI(confirm_url)
35
+ req = Net::HTTP::Post.new(uri)
36
+ Net::HTTP.start(uri.hostname, uri.port) do |http|
37
+ http.request(req)
38
+ end
39
+ end
40
+ update(status: Export::COMPLETE)
41
+ if Rails.application.config.respond_to?(:apidae_import_callback)
42
+ Rails.application.config.apidae_import_callback.call(self)
43
+ end
44
+ rescue Exception => ex
45
+ logger.error("Failed to import export file : #{file_url}")
46
+ logger.error("Error is : #{ex} \n#{ex.backtrace.join("\n") unless ex.backtrace.blank?}")
47
+ success = false
48
+ update(status: Export::CANCELLED)
49
+ end
50
+ end
51
+ rescue OpenURI::HTTPError => err
52
+ logger.error("Failed to download export file : #{file_url}")
53
+ logger.error("Error is : #{err}")
54
+ success = false
55
+ update(status: Export::CANCELLED)
56
+ rescue Exception => e
57
+ logger.error "Failed to import file : #{e.file_url}"
58
+ logger.error("Error is : #{err}")
59
+ success = false
60
+ e.update(status: Export::CANCELLED)
61
+ end
62
+ success
63
+ end
23
64
  end
24
65
  end
@@ -30,21 +30,18 @@ module Apidae
30
30
  Town.import(zfile.read(TOWNS_FILE))
31
31
  logger.info "Completed #{Town.count} towns update"
32
32
  end
33
- ordered_files(zfile).each do |file|
33
+ 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
- end
39
- if file.name.include?(SELECTIONS_FILE)
40
- add_or_update_selections(project, zfile.read(file.name), result)
41
- end
42
- if file.name.include?(DELETED_FILE)
38
+ elsif file.name.include?(DELETED_FILE)
43
39
  delete_objects(zfile.read(file.name), result)
40
+ elsif file.name.include?(SELECTIONS_FILE)
41
+ add_or_update_selections(project, zfile.read(file.name), result)
44
42
  end
45
43
  end
46
44
  end
47
- project.cleanup_selections
48
45
  create(result.except(:selections)
49
46
  .merge({remote_file: (zip_file.is_a?(File) ? zip_file.path : zip_file), status: STATUS_COMPLETE, apidae_id: project_id}))
50
47
  logger.info "Import results : #{result}"
@@ -107,16 +104,12 @@ module Apidae
107
104
  end
108
105
  end
109
106
 
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
-
114
107
  def self.delete_objects(deleted_json, result)
115
108
  deleted_ids = JSON.parse(deleted_json)
116
109
  deleted_ids.each do |id|
117
110
  obj = Obj.find_by_apidae_id(id)
118
111
  if obj
119
- obj.destroy! if obj.selections.empty?
112
+ obj.destroy!
120
113
  result[:deleted] += 1
121
114
  else
122
115
  logger.info "skipping object deletion : #{id}"
@@ -170,9 +163,7 @@ module Apidae
170
163
  def self.add_or_update_selections(project, selections_json, result)
171
164
  selections_hashes = JSON.parse(selections_json, symbolize_names: true)
172
165
  deleted_ids = Selection.where(apidae_project_id: project.id).collect {|sel| sel.apidae_id}.uniq - selections_hashes.collect {|sel| sel[:id]}
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
166
+ Selection.where(apidae_id: deleted_ids).delete_all
176
167
  selections_hashes.each do |selection_data|
177
168
  logger.info "Updating selection #{selection_data[:id]}"
178
169
  Selection.add_or_update(selection_data, project.id)
@@ -7,24 +7,22 @@ module Apidae
7
7
 
8
8
  attr_accessor :locale
9
9
  attr_accessor :obj_version
10
- attr_accessor :obj_versions
11
10
 
12
11
  store_accessor :title_data, :title
13
12
  store_accessor :owner_data, :owner_name, :owner_id
14
13
  store_accessor :description_data, :short_desc, :long_desc, :theme_desc, :private_desc
15
14
  store_accessor :pictures_data, :pictures
16
15
  store_accessor :attachments_data, :attachments
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
16
+ store_accessor :type_data, :categories, :themes, :capacity, :classification, :labels, :chains, :area, :track,
17
+ :products, :audience, :animals, :animals_desc, :extra, :duration, :certifications, :business
18
+ store_accessor :entity_data, :entity_id, :entity_name, :service_provider_id
21
19
  store_accessor :contact_data, :telephone, :email, :website, :google, :facebook, :twitter, :yelp, :trip_advisor, :fax,
22
20
  :mobile_website, :shorty_url, :contacts
23
- store_accessor :location_data, :address, :place, :latitude, :longitude, :access, :territories, :environments, :altitude, :map_reference
21
+ store_accessor :location_data, :address, :place, :latitude, :longitude, :access, :territories, :environments
24
22
  store_accessor :openings_data, :openings_desc, :openings_desc_mode, :openings, :time_periods, :openings_extra
25
- store_accessor :rates_data, :rates_desc, :rates_desc_mode, :rates, :payment_methods, :includes, :excludes, :rates_extra, :tax_included
23
+ store_accessor :rates_data, :rates_desc, :rates_desc_mode, :rates, :payment_methods, :includes, :excludes, :rates_extra
26
24
  store_accessor :service_data, :services, :equipments, :comfort, :activities, :challenged, :languages
27
- store_accessor :booking_data, :booking_desc, :booking_entities, :visits_allowed, :visits_desc, :visits_duration, :visits_services
25
+ store_accessor :booking_data, :booking_desc, :booking_entities
28
26
  store_accessor :tags_data, :promo, :internal, :linked
29
27
  store_accessor :version_data, :versioned_fields
30
28
 
@@ -85,7 +83,7 @@ module Apidae
85
83
  COS => {node: :informationsCommerceEtService, subtype: :commerceEtServiceType},
86
84
  DEG => {node: :informationsDegustation, subtype: :degustationType},
87
85
  DOS => {node: :informationsDomaineSkiable, subtype: :domaineSkiableType},
88
- EQU => {node: :informationsEquipement, subtype: :rubrique},
86
+ EQU => {node: :informationsEquipement, subtype: :equipementType},
89
87
  FEM => {node: :informationsFeteEtManifestation, subtype: :feteEtManifestationType},
90
88
  HCO => {node: :informationsHebergementCollectif, subtype: :hebergementCollectifType},
91
89
  HLO => {node: :informationsHebergementLocatif, subtype: :hebergementLocatifType},
@@ -102,7 +100,6 @@ module Apidae
102
100
  after_initialize do
103
101
  @locale = DEFAULT_LOCALE
104
102
  @obj_version = DEFAULT_VERSION
105
- @obj_versions = {}
106
103
  end
107
104
 
108
105
  def root_obj
@@ -114,15 +111,11 @@ module Apidae
114
111
  end
115
112
 
116
113
  def in_version(v)
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]
114
+ @cached_versions ||= {}
115
+ if @cached_versions[v].nil?
116
+ @cached_versions[v] = versions.where(version: v).first
125
117
  end
118
+ @cached_versions[v]
126
119
  end
127
120
 
128
121
  def in_locale(l)
@@ -171,7 +164,6 @@ module Apidae
171
164
  apidae_obj
172
165
  end
173
166
 
174
- # Note : overrides existing fields (not a merge)
175
167
  def self.populate_fields(apidae_obj, object_data, locales)
176
168
  type_fields = TYPES_DATA[object_data[:type]]
177
169
  apidae_obj.last_update = DateTime.parse(object_data[:gestion][:dateModification]) unless object_data[:gestion].blank?
@@ -186,12 +178,12 @@ module Apidae
186
178
  apidae_obj.town = ApidaeDataParser.parse_town(object_data[:localisation])
187
179
  apidae_obj.openings_data = ApidaeDataParser.parse_openings(object_data[:ouverture], *locales)
188
180
  apidae_obj.rates_data = ApidaeDataParser.parse_rates(object_data[:descriptionTarif], *locales)
189
- apidae_obj.booking_data = ApidaeDataParser.parse_booking(object_data[:reservation], object_data[:visites], *locales)
181
+ apidae_obj.booking_data = ApidaeDataParser.parse_booking(object_data[:reservation], *locales)
190
182
  apidae_obj.type_data = ApidaeDataParser.parse_type_data(apidae_obj, object_data[type_fields[:node]], object_data[:prestations],
191
183
  object_data[:tourismeAffaires], *locales)
192
184
  apidae_obj.pictures_data = ApidaeDataParser.parse_pictures_data(object_data[:illustrations], *locales)
193
185
  apidae_obj.attachments_data = ApidaeDataParser.parse_attachments_data(object_data[:multimedias], *locales)
194
- apidae_obj.entity_data = ApidaeDataParser.parse_entity_fields(object_data[:informations], object_data[type_fields[:node]], object_data[:informationsPrestataireActivites])
186
+ apidae_obj.entity_data = ApidaeDataParser.parse_entity_fields(object_data[:informations], object_data[type_fields[:node]])
195
187
  apidae_obj.service_data = ApidaeDataParser.parse_service_data(object_data[:prestations], object_data[type_fields[:node]])
196
188
  apidae_obj.tags_data = ApidaeDataParser.parse_tags_data(object_data[:presentation], object_data[:criteresInternes], object_data[:liens])
197
189
  apidae_obj.meta_data = object_data[:metadonnees]
@@ -20,11 +20,5 @@ module Apidae
20
20
  def versions=(values)
21
21
  self.versions_data = values.blank? ? nil : values.join('|')
22
22
  end
23
-
24
- def cleanup_selections
25
- apidae_selections.reload.each do |s|
26
- s.cleanup
27
- end
28
- end
29
23
  end
30
24
  end
@@ -10,7 +10,7 @@ module Apidae
10
10
  end
11
11
 
12
12
  def self.import(refs_json)
13
- locales = Rails.application.config.respond_to?(:apidae_locales) ? Rails.application.config.apidae_locales : [DEFAULT_LOCALE]
13
+ locales = Rails.application.config.respond_to?(:apidae_locales) ? Rails.application.config.apidae_locales : [DEFAULT_LOCALE]
14
14
  locales_map = Hash[locales.map {|loc| ["libelle#{loc.camelize.gsub('-', '')}".to_sym, loc]}]
15
15
  refs_hashes = JSON.parse(refs_json, symbolize_names: true)
16
16
  if refs_hashes.length != where("apidae_type != ?", INTERNAL).count
@@ -42,20 +42,6 @@ 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
-
59
45
  def results(where_clause, offset, size)
60
46
  objects.includes(:town).limit(size).offset(offset).where(where_clause)
61
47
  end
@@ -106,7 +92,6 @@ module Apidae
106
92
  query_api(query_args, true, false)
107
93
  end
108
94
 
109
- # Note : WARNING - updated obj will only contain the provided fields
110
95
  def add_or_refresh_obj(apidae_obj_id, fields = ["@all"])
111
96
  if valid_api?
112
97
  res = api_object(apidae_obj_id, fields)
@@ -117,7 +102,6 @@ module Apidae
117
102
  end
118
103
  end
119
104
 
120
- # Note : WARNING - updated objs will only contain the provided fields
121
105
  def add_or_refresh_objs(fields = ["@all"])
122
106
  if valid_api?
123
107
  res = api_objects({fields: fields})
@@ -8,10 +8,9 @@ module Apidae
8
8
  LOCALE_ZH = 'zh'
9
9
  LOCALE_ES = 'es'
10
10
  LOCALE_PT_BR = 'pt-BR'
11
- LOCALE_JP = 'jp'
12
11
 
13
12
  DEFAULT_LOCALE = LOCALE_FR
14
- ALL_LOCALES = [LOCALE_FR, LOCALE_EN, LOCALE_IT, LOCALE_DE, LOCALE_NL, LOCALE_RU, LOCALE_ZH, LOCALE_ES, LOCALE_PT_BR, LOCALE_JP]
13
+ ALL_LOCALES = [LOCALE_FR, LOCALE_EN, LOCALE_IT, LOCALE_DE, LOCALE_NL, LOCALE_RU, LOCALE_ZH, LOCALE_ES, LOCALE_PT_BR]
15
14
 
16
15
  STANDARD_VERSION = 'STANDARD'
17
16
  WINTER_VERSION = 'HIVER'
@@ -25,11 +24,8 @@ module Apidae
25
24
  ALL_VERSIONS = [STANDARD_VERSION, WINTER_VERSION, SUMMER_VERSION, CHALLENGED_VERSION, BUSINESS_VERSION,
26
25
  GROUPS_VERSION, ACTIVITIES_VERSION]
27
26
 
28
- LOCALIZED_FIELDS = [:title, :short_desc, :long_desc, :pictures, :attachments,
29
- :openings_desc, :rates_desc, :includes, :excludes, :extra, :booking_desc]
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]
27
+ LOCALIZED_FIELDS = [:title, :short_desc, :long_desc, :pictures, :attachments, :openings_desc, :rates_desc,
28
+ :includes, :excludes, :extra, :booking_desc]
29
+ ALL_FIELDS = LOCALIZED_FIELDS + [:theme_desc, :private_desc, :capacity, :telephone, :email, :website, :services,
30
+ :equipments, :comfort, :activities, :promo, :internal, :linked]
35
31
  end
@@ -41,7 +41,6 @@ fr:
41
41
  ru: Russe
42
42
  zh: Chinois
43
43
  'pt-BR': Brésilien
44
- jp: Japonais
45
44
  versions:
46
45
  STANDARD: Standard
47
46
  HIVER: Hiver
@@ -1,3 +1,3 @@
1
1
  module Apidae
2
- VERSION = "1.2.27"
2
+ VERSION = "1.3.0"
3
3
  end
@@ -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: 2020_05_28_101957) do
13
+ ActiveRecord::Schema.define(version: 2020_05_22_124205) do
14
14
 
15
15
  # These are extensions that must be enabled in order to support this database
16
16
  enable_extension "plpgsql"
@@ -92,10 +92,8 @@ ActiveRecord::Schema.define(version: 2020_05_28_101957) 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"
96
95
  t.index ["apidae_id"], name: "index_apidae_references_on_apidae_id"
97
96
  t.index ["apidae_type"], name: "index_apidae_references_on_apidae_type"
98
- t.index ["is_active"], name: "index_apidae_references_on_is_active"
99
97
  end
100
98
 
101
99
  create_table "apidae_selection_objects", force: :cascade do |t|
@@ -1,24 +1,67 @@
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)
1
+ Apidae::Obj Load (1.5ms) SELECT "apidae_objs".* FROM "apidae_objs" ORDER BY "apidae_objs"."id" ASC LIMIT $1 [["LIMIT", 1]]
2
+  (0.2ms) SELECT pg_try_advisory_lock(6140174353533887940)
3
+  (1.7ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
4
+ Migrating to AddProjectIdToSelections (20181024072424)
5
+  (0.2ms) BEGIN
6
+  (39.2ms) ALTER TABLE "apidae_selections" ADD "apidae_project_id" integer
7
+ ActiveRecord::SchemaMigration Create (0.4ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version" [["version", "20181024072424"]]
8
+  (0.8ms) COMMIT
9
+ Migrating to CreateApidaeProjects (20181024072843)
10
+  (0.1ms) BEGIN
11
+  (56.9ms) CREATE TABLE "apidae_projects" ("id" bigserial primary key, "name" character varying, "apidae_id" integer, "api_key" character varying, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL)
12
+ ActiveRecord::SchemaMigration Create (0.2ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version" [["version", "20181024072843"]]
13
+  (2.1ms) COMMIT
14
+ Migrating to AddApidaeIdToApidaeFileImports (20190111162443)
15
+  (40.0ms) BEGIN
16
+  (0.6ms) ALTER TABLE "apidae_file_imports" ADD "apidae_id" integer
17
+ ActiveRecord::SchemaMigration Create (0.4ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version" [["version", "20190111162443"]]
18
+  (0.6ms) COMMIT
19
+ Migrating to UpgradeApidaeObjsTitleDataType (20190123142628)
20
+  (0.1ms) BEGIN
21
+  (0.4ms) ALTER TABLE "apidae_objs" ADD "title_data" jsonb
22
+ Apidae::Obj Load (0.5ms) SELECT "apidae_objs".* FROM "apidae_objs"
23
+  (1.4ms) ALTER TABLE "apidae_objs" DROP COLUMN "title"
24
+ ActiveRecord::SchemaMigration Create (0.2ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version" [["version", "20190123142628"]]
25
+  (0.4ms) COMMIT
26
+ ActiveRecord::InternalMetadata Load (1.9ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2 [["key", "environment"], ["LIMIT", 1]]
27
+  (0.2ms) BEGIN
28
+  (0.1ms) COMMIT
29
+  (0.2ms) SELECT pg_advisory_unlock(6140174353533887940)
30
+  (0.2ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
31
+  (0.3ms) SELECT pg_try_advisory_lock(6140174353533887940)
32
+  (3.6ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
33
+ Migrating to AddBookingDataToApidaeObjs (20190123160046)
34
+  (0.2ms) BEGIN
35
+  (0.7ms) ALTER TABLE "apidae_objs" ADD "booking_data" jsonb
36
+ Apidae::Obj Load (1.0ms) SELECT "apidae_objs".* FROM "apidae_objs"
37
+  (0.5ms) ALTER TABLE "apidae_objs" DROP COLUMN "reservation"
38
+ ActiveRecord::SchemaMigration Create (0.3ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version" [["version", "20190123160046"]]
39
+  (0.6ms) COMMIT
40
+ ActiveRecord::InternalMetadata Load (0.7ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2 [["key", "environment"], ["LIMIT", 1]]
41
+  (0.2ms) BEGIN
42
+  (0.1ms) COMMIT
43
+  (0.2ms) SELECT pg_advisory_unlock(6140174353533887940)
44
+  (0.2ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
45
+  (4.5ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
46
+  (0.2ms) SELECT pg_try_advisory_lock(6140174353533887940)
47
+  (0.6ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
48
+ Migrating to AddLocalesDataToApidaeProjects (20190123214635)
49
+  (0.2ms) BEGIN
50
+  (3.2ms) ALTER TABLE "apidae_projects" ADD "locales_data" character varying
51
+ ActiveRecord::SchemaMigration Create (0.3ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version" [["version", "20190123214635"]]
52
+  (0.5ms) COMMIT
53
+ ActiveRecord::InternalMetadata Load (42.2ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2 [["key", "environment"], ["LIMIT", 1]]
54
+  (0.2ms) BEGIN
55
+  (0.1ms) COMMIT
56
+  (0.2ms) SELECT pg_advisory_unlock(6140174353533887940)
57
+  (0.2ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
58
+  (0.5ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
59
+  (0.2ms) SELECT pg_try_advisory_lock(6140174353533887940)
60
+  (0.5ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
61
+ ActiveRecord::InternalMetadata Load (0.4ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2 [["key", "environment"], ["LIMIT", 1]]
62
+  (0.2ms) BEGIN
63
+  (0.2ms) COMMIT
64
+  (0.2ms) SELECT pg_advisory_unlock(6140174353533887940)
65
+  (0.2ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
66
+ Apidae::Obj Load (26.8ms) SELECT 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)
67
+ Apidae::Obj Load (2.4ms) SELECT 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)